This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Slim templates syntax for Jinja2 templates

Project Description
## [Slim]( templates syntax for Jinja2.

#### Installation

pip install slimish_jinja

Examples of using it as `Jinja2 extension(`,
with `Flask(` and standalone`( and` are bundled.

If you want to use it for any other purpose, the `lexer -` and `parser -` 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::

/ Inline static content.
- block title
|Slimish-Jinja Example
/ Self closing tag with attributes.
meta name="keywords" content="template language"
- assets filters='jsmin', output='gen/packed.js', 'common/jquery.js', 'site/base.js'
%script type="text/javascript" src="{{ ASSET_URL }}"
/ Empty jinja tag.
@block script

/ 'id' and 'class' shortcut.
/ Nested static content.
|This is my header.
/ 'div' with 'id' and 'class' shortcut.
/ Empty html tag.
p Dynamic {{ content }}
|Nested dyanmic {{ content }}
Left indent is preserved in text blocks.
|<a href="">Google</a>
/ Dynamic attributes.
ul class="{{ user_class }}"
/ Jinja tag.
- for user in users
li {{ }}
- 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>
{% block title %}
Slimish-Jinja Example
{% endblock %}
<meta content="template language" name="keywords"/>
{% block script %}{% endblock %}
<body id="home" class="fluid liquid">
This is my header.
<div id="contents" class="main">
<p>Dynamic {{ content }}</p>
Nested dyanmic {{ content }} Left indent is preserved in text blocks.
<a href="">ThoughtNirvana</a>
<ul class="{{ user_class }}">
{% for user in users %}
<li>{{ }}</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 %}

#### Doctype delcarations.

<!DOCTYPE html>

<!DOCTYPE html>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "">

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN" "">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "">

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "">

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">

#### Static content

/ Inline static content.
h1 This is my header

/ Nested static content.
|This is my header

/ Multiline static content.
|Span mutliple lines.
Left indent preserved in the output.

#### Dynamic content

/ Inline
h1 {{ user.title }}

/ Nested
{{ user.title }}

/ Mixed with text.
|The user name is {{ }}

#### Jinja tags

- for user in users
li {{ }}
- if {{ user.lastname }}
li {{ user.lastname }}
- else
li No users found

#### Dynamic contents in attribute

a href="{{ user.url }}" {{ }}

#### **id** and **classname** shortcuts

#contents.main.liquid => <div id="contents" class="main liquid">

body#home.left => <body id="home" class="left">

#### Code comments.

/ Single slash comments.
/ Not part of the output.
p This is content.

#### Empty html tags

%div => <div></div>

#### Empty jinja tags.

@block title => {%block title %}{% endblock %}
Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
slimish_jinja-1.0.2.tar.gz (9.7 kB) Copy SHA256 Checksum SHA256 Source Aug 4, 2013

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting