semirook / jinja-atoms Goto Github PK
View Code? Open in Web Editor NEWAtomic inclusion blocks extension for Jinja2 template engine
License: Other
Atomic inclusion blocks extension for Jinja2 template engine
License: Other
I have a template using {% include %}
and the included template has some atoms.
On first page load, the atoms are undefined:
loaded_atom_055b68d1c94337b4abfa8c6ef6e9730a Undefined
loaded_atom_597e00885ae82a76607f002e8a862c05 Undefined
loaded_atom_a6eb20402166d69767bdc9816f3df9fe <function atom_args at 0x4c9fb18>
And that makes jinja2 raise an UndefinedError
.
Any ideas about that?
>>> import re
>>> regex = re.compile(
... r'\{\%\s*use\s+atoms\s*\'?(?P<tmpl>[^\s]+)\'?\s*as\s*\'?(?P<context>\w+)\'?\s*\%\}',
... )
>>>
>>> m = re.findall(regex, '{%use atomsblargbazasfoobar%}')
>>> m
[('blargbaz', 'foobar')]
Hi,
I'm integrating your awesome extension but am facing a difficulty when using something with a dot:
{% atom documents:search_result_item(result.document) %}
Doesn't work, I get a parse error:
Exception Type: TemplateSyntaxError
Exception Value: expected token ',', got '.'
So far, the only solution I get is this:
{% set doc = result.document %}
{% atom documents:search_result_item(doc) %}
Which is far from ideal.
I guess it's parse method in the extension which is not flexible enough.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.