slimish_jinja

Slim templates syntax for Jinja2 templates
Download

slimish_jinja Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Rahul Kumar
  • Publisher web site:

slimish_jinja Tags


slimish_jinja Description

slimish_jinja package provides Slim templates syntax for Jinja2.InstallationI will be uploading it to PyPi soon. By then, clone the repository. Examples of using it as `Jinja2 extension(jinja_demo.py)`, with `Flask(flask_demo.py)` and standalone`(convert.py and demo.py)` are bundled.If you want to use it for any other purpose, the `lexer - lexer.py` and `parser - parser.py` are simple enough. `lexer` reads the input by lines and generates tokens. `parser` implements a hand rolled recursive descent parser.For quick reference, this slim:: !5 html head / Inline static content. title -block title |Slimish-Jinja Example / Self closing tag with attributes. meta name="keywords" content="template language" script / Empty jinja tag. @block script / 'id' and 'class' shortcut. body#home.fluid.liquid / Nested static content. h1 |This is my header. / 'div' with 'id' and 'class' shortcut. #contents.main / Empty html tag. %div p Dynamic =content p |Nested dyanmic =content Left indent is preserved in text blocks. / Mixing html is fine as well. p |< a href\="http://www.thoughtnirvana.com" >ThoughtNirvana< /a > / Dynamic attributes. ul class="=user_class" / Jinja tag. -for user in users li =user.name -if user.last_name li =user.last_name -elif user.middle_name li =user.middle_name -else li No user found.converts to: < !doctype html > < html > < head > < title > {% block title %} Slimish-Jinja Example {% endblock %} < /title > < meta content="template language" name="keywords"/ > < script > {% block script %}{% endblock %} < /script > < /head > < body id="home" class="fluid liquid" > < h1 > This is my header. < /h1 > < div id="contents" class="main" > < div >< /div > < p >Dynamic {{ content }}< /p > < p > Nested dyanmic {{ content }} Left indent is preserved in text blocks. < /p > < p > < a href="http://www.thoughtnirvana.com" >ThoughtNirvana< /a > < /p > < /div > < ul class="{{ user_class }}" > {% for user in users %} < li >{{ user.name }}< /li > {% if user.last_name %} < li >{{ user.last_name }}< /li > {% elif user.middle_name %} < li >{{ user.middle_name }}< /li > {% endif %} {% else %} < li >No user found.< /li > {% endfor %} < /ul > < /body > < /html >Product's homepage


slimish_jinja Related Software