Reputation: 876
I am trying to use jinja2 as follows.
Suppose,
Following are tags:
tags: {"world":"WORLD", "c language": "Dennis Ritchie", "apple":"JOBS" }
Input:
HELLO {{ world }}, C is written by **{{ c language }}**, **}}** while **{{** java is written by {{ java }}, hola.
Output:
HELLO WORLD, C is written by Dennis Ritchie, **}}** while **{{** java is written by, hola.
So in short there are following things I have to do.
Out of 4, for only 1 & 2 jinja2 is working fine.
from jinja2 import Template
t = Template(input_string)
t.render(context)
But for 3rd & 4th, it's not working.(or I am mistaking.)
I found only 1 template engine called "mustache" which supports above all 4 conditions. But I don't know how it works in case of performance.
As jinja2 is mature template engine, I think it's possible to customize default behaviour.
Can anybody know solution?
Thnx in advance.
My primary testing shows that Mustache(Pystache) is too faster than jinja2. If possible please give expert opinion.
https://github.com/defunkt/pystache
Upvotes: 1
Views: 537
Reputation: 876
Finally I continue with mustache. It's really awesome template engine.
For mustache build for python
https://github.com/defunkt/pystache
Upvotes: 1
Reputation: 2334
I don't think this is possible. The documentation is quite clear on identifiers:
Jinja2 uses the regular Python 2.x naming rules. Valid identifiers have to match [a-zA-Z_][a-zA-Z0-9_]*. As a matter of fact non ASCII characters are currently not allowed. This limitation will probably go away as soon as unicode identifiers are fully specified for Python 3.
Upvotes: 0