Templating in Brython?
See original GitHub issueHello guys, and congratulations for this great work: it’s a real pleasure to finally work with a comfortable language in the browser…
My question is about templating: in almost all apps I build client side, I need to format templates (walk over dicts, check conditions, replace values…).
Here is an example of such a template I used to code with Riot.js:
<ul>
<li each={ tag in tags }>{ tag.text }</li>
</ul>
On server side Python, I usually use Jinja to achieve this.
How do you proceed in Brython code? Python’s string format()
is a very limited solution (no loops, no conditions…). Importing Jinja in Brython program seems touchy…
Thank you very much in advance!
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
module browser.template - Brython documentation
The module template allows to dynamically generate some elements in a page, by including Python code blocks or expressions inside the HTML code....
Read more >Creating a document - Brython
Hello world ! Insert content in an element · HTML markup (bold,italic...) HTML table · Bind and unbind events · Handle options in...
Read more >interpreter - Brython documentation
This module provides classes to open a Python interactive interpreter in a page. It is used by the console and the editor of...
Read more >Problem - Brython documentation
Problem. Validate the content of a form before sending it to the server. Solution. In the form below we want to check that...
Read more >Syntax, keywords and built-in functions - Brython documentation
Brython supports all the keywords and functions of the Python version with the same version number. Here are a few features and limitations...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I started evaluating Jinja2 on Brython: a few issues have been opened (and resolved) in the past weeks. I’ll continue my work as soon as possible.
A fork will be required: some features (like bytecode cache) will not be compatible with Brython.
After many trials and errors , I have a working version of the browser.template module (see the documentation). It is vaguely inspired by vue.js.
I have also added a version of the “sort table” demo using it, is is much more concise than the version with browser.html to generate HTML code.
Feedback is very much welcome. I will also post a message on the Google group.