jonbretman / jinja-to-js Goto Github PK
View Code? Open in Web Editor NEWConvert Jinja2 templates into Underscore style templates for use in the browser.
License: Apache License 2.0
Convert Jinja2 templates into Underscore style templates for use in the browser.
License: Apache License 2.0
Very Interesting solution. I'm a fan of Python Jinja. But I ask myself the following. I use Jinja to render pages and fragments. I use fetch and the DOM to paste those fragments in my SPA pages. All async. Why would I render client-side in this setup?
Example: I have a page with a table. The first GET renders the whole page. When I need to update the table I use JSON fetch requests, which returns json with rendered html fragments (fi a table body) to update the DOM. JInja is fast, templates can be pre-compiled and minified. How / where can I benefit from your interesting solution.
Hi there,
I'm playing around with this project to see if we could use it to share template code between our client and server. So far it looks very promising!
Unfortunately, we use AngularJS dependency injection instead of modules and bower instead of npm for dependencies, which means installing the runtime was a bit of a challenge. I had to copy the runtime file, which isn't too big a big deal although it would be nice to have instructions to do so if you don't use npm.
Part of the challenge was due to one small bug: the module definition wrapper has a misnamed variable in the non-AMD, non-CommonJS case. root
should be global
in the immediately invoked expression at the top of the file.
This is trivial to fix, but if you'd like I'm happy to make a pull request.
Thanks!
Tom
Thanks for the awesome library:
I was having some trouble getting {% with %}{% endwith %} to work. I even grabbed the test case out of the projects template directory (with.jinja).
Here is the command I ran:
jinja_to_js ./templates with.jinja -m es6 -o ./js/with_jinja.js
Traceback (most recent call last):
File "/usr/local/bin/jinja_to_js", line 9, in
load_entry_point('jinja-to-js==3.1.0', 'console_scripts', 'jinja_to_js')()
File "/Library/Python/2.7/site-packages/jinja_to_js/main.py", line 92, in main
compiler = JinjaToJS(**get_init_kwargs(options))
File "/Library/Python/2.7/site-packages/jinja_to_js/init.py", line 245, in init
self._process_node(node)
File "/Library/Python/2.7/site-packages/jinja_to_js/init.py", line 306, in _process_node
raise Exception('Unknown node %s' % node)
Exception: Unknown node With(targets=[], values=[], body=[Output(nodes=[TemplateData(da etc...
Am i doing something wrong? Thanks a lot!
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.