A Library to Quickly Turn Functions into Jinja2 Extensions
==========================================================
This library is best demonstrated through example:
```python
import jinjatag
### Configure your Jinja2 Environment:
jinja_tag = jinjatag.JinjaTag()
jinja2_env = Environment(extensions=[jinja_tag])
jinja_tag.init()
### Decorate your functions
@jinjatag.simple_tag()
def mytag(foo, bar=None, **kwargs):
return "mytag: "+foo+(bar or '')+str(kwargs)
@jinjatag.simple_block()
def myblock(body, foo, bar=None):
return "myblock : "+body+foo+(bar or '')
```
Then, in your template code, use your new tags:
{% mytag foo='abc' xyz='def' %}
{% myblock foo='bar' %}contents{% endmyblock %}
The resulting output:
mytag: abc{'xyz':'def'}
myblock: contentsbar
That's really all there is to it. A simple_tag is expected to accept 0 or more arguments and return a string. A simple_block is expected to accept at least one argument which will be its rendered body.
Install
-------
The module is registered with pypi, so simply use:
easy_install jinjatag
or, if you're so inclined:
pip install jinjatag
Further Documentation
----------------------
More documentation is available at http://mankyd.github.com/jinjatag/
Also, tests are available in https://github.com/mankyd/jinjatag/tree/master/jinjatag/tests
License
--------
GPL v3
Authors
-------
Dave Mankoff
Mike Axiak
==========================================================
This library is best demonstrated through example:
```python
import jinjatag
### Configure your Jinja2 Environment:
jinja_tag = jinjatag.JinjaTag()
jinja2_env = Environment(extensions=[jinja_tag])
jinja_tag.init()
### Decorate your functions
@jinjatag.simple_tag()
def mytag(foo, bar=None, **kwargs):
return "mytag: "+foo+(bar or '')+str(kwargs)
@jinjatag.simple_block()
def myblock(body, foo, bar=None):
return "myblock : "+body+foo+(bar or '')
```
Then, in your template code, use your new tags:
{% mytag foo='abc' xyz='def' %}
{% myblock foo='bar' %}contents{% endmyblock %}
The resulting output:
mytag: abc{'xyz':'def'}
myblock: contentsbar
That's really all there is to it. A simple_tag is expected to accept 0 or more arguments and return a string. A simple_block is expected to accept at least one argument which will be its rendered body.
Install
-------
The module is registered with pypi, so simply use:
easy_install jinjatag
or, if you're so inclined:
pip install jinjatag
Further Documentation
----------------------
More documentation is available at http://mankyd.github.com/jinjatag/
Also, tests are available in https://github.com/mankyd/jinjatag/tree/master/jinjatag/tests
License
--------
GPL v3
Authors
-------
Dave Mankoff
Mike Axiak
Metadata
Release files for jinjatag 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jinjatag-0.1.6.tar.gz | 13.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jinjatag-0.1.6-py2.7.egg | Legacy Egg format | - | - | Details |
Total release size: 23.1 kB
Release files / jinjatag-0.1.6.tar.gz
| Download URL | jinjatag-0.1.6.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7083eb15d9a0f5417c2e5b9bd353b06cfbf5445bb55974a8ac2b69017138cab8
|
|
BLAKE2b-256 checksum How to use checksums |
cbc455baf2d879c06626bec4132eb993739562ebf78ca62ca19edc8a4b01bc61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / jinjatag-0.1.6-py2.7.egg
| Download URL | jinjatag-0.1.6-py2.7.egg |
|---|---|
| Size | 9.6 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
1a9ed284ca6092e3742cb2ecefe9b966aaa2acfe092b61819e38210f9d32ce91
|
|
BLAKE2b-256 checksum How to use checksums |
27902421a2b1276d4493a0eab94db01a0017f577b4f5a755da6ef9f3628ce976
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |