2010-03-25 python jinja bottle
jinja2 - Популярная и многофункциональная система темплейтов, оф. документация
easy_install jinja2
# coding: utf-8
from bottle import jinja2_template as template
# Вывод параметров
print template('hello {{name}}', name = 'world')
# hello world
# Словари
print template("hello {{dim['name']}}, age = {{dim['age']}}", dim = {'name':'User', 'age': 20})
# hello User, age = 20
# Классы
class User:
name = 'noname'
age = 20
user = User()
print template('hello {{user.name}}, age = {{user.age}}', user = user)
# hello noname, age = 20
# Циклы
print template('System: {% for sys in dim %}{{sys}}, {% endfor %}', dim = ['linux','windows','mac'])
# System: linux, windows, mac,
# Уловия
print template('this if: {% if name: %}name exsist, this {{name}}{% endif %}', name = 'world')
# this if: name exsist, this world