slimish_jinja 1.0.1

Slim templates syntax for Jinja2 templates
slimish_jinja package provides Slim templates syntax for Jinja2.

Installation

I 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 >

last updated on:
May 23rd, 2012, 9:40 GMT
price:
FREE!
homepage:
github.com
license type:
BSD License 
developed by:
Rahul Kumar
category:
ROOT \ Internet \ HTTP (WWW)
slimish_jinja
Download Button

In a hurry? Add it to your Download Basket!

user rating

UNRATED
0.0/5
 

0/5

Rate it!

Add your review!

SUBMIT