Jinja2 extension that removes whitespace between HTML tags
Project description
Example usage:
env = Environment(extensions=['j2hc.compressors.HTMLCompress'])
or for the coffin users:
JINJA2_EXTENSIONS = [ 'j2hc.compressors.HTMLCompress' ]
How does it work? It throws away all whitespace between HTML tags it can find at runtime. It will however preserve pre, textarea, style and script tags because this kinda makes sense. There is one exception for script tags, that contain an angularjs template:
<script type="test/ng-template" ....
In order to force whitespace you can use {{ " " }}.
Unlike filters that work at template runtime, this remotes whitespace at compile time and does not add an overhead in template execution.
What if you only want to selective strip stuff?:
env = Environment(extensions=['j2hc.compressors.SelectiveHTMLCompress'])
And then mark blocks with:
{% strip %} ... {% endstrip %}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file j2hc-0.1.1.tar.gz
.
File metadata
- Download URL: j2hc-0.1.1.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9eb07db3d36cd84bb444e4b8385f59e71fc03b8cb3341573b6a3ac4cf4d1c93 |
|
MD5 | b31a6efdc1e93716b60c351345d4088f |
|
BLAKE2b-256 | ceacdd13def69264112607b94786e72f098d5a451f3b4cc006bcaf727a944868 |