Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced compress template tag #285

Conversation

jannon
Copy link

@jannon jannon commented Jul 15, 2012

Background

I used and heavily modified django-compress for a while, but needed something else when the project stalled. Django_compressor offered some continuity (filters/extensibility) and some very welcome differences (parsing blocks from the code). I would like to see django_compressor be the basis for a full modern web asset handling package, that works well with modern best practises (e.g. asynchronous asset loaders, css sprites, etc). To that end, my plan is to start with django_compressor's extensibility, enhance it a little bit, then build some useful stuff on top of it (e.g. filters/compilers for images). The first step, however is just adding a little more flexibility and standardization to the template tag

What's in this pull request

  • Let tag arguments after kind (css|js) be specified in any order
  • Use more standard 'as ' syntax to name the code block
  • Add ability to specify options in the tag

There are tests and documentation updates as well as the code changes

Tag Argument Order

There's not really any need to enforce a certain arrangement of arguments in the tag so let's just let people specify them however they want after the kind parameter. So now all of these are valid:

{% compress js inline as main %}

{% compress js as main file %}

{% compress css group_first=true as base %}

Using 'as <name>'

Lots of things in python and django use this syntax, so it would be nice to do so as well

Specifying options in the tag

Here's the big one. Just like the with tag in django, you can specify an arbitrary number of keyword/value arguments to the tag. These will get put into a dictionary and passed to the Compressor classes. Also, the default compressors, add these to the options that they pass the precompilers and filters. One of the main motivations for this was to prepare for being able to specify that files should be grouped first before, say, lessc precompilation (as discussed in #30)

@travisbot
Copy link

This pull request fails (merged 9a04992 into 3723a67).

@jannon
Copy link
Author

jannon commented Jul 16, 2012

Soo....what's up with the travis integration? the flake8 errors are all in code not touched by this pull request. How was the build passing before?

jannon added a commit to xtranormal/django_compressor that referenced this pull request Jul 16, 2012
setting the option 'group_first=true' in the template tag (requires django-compressor#285) will cause files of like type to be concatenated before being handed to precompilers/filters.  This will allow people to do standard code decomposition with things like less files (having a mixins file separate from page-specific files)
@jannon jannon closed this Jul 17, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants