タグ

JInja2に関するideoのブックマーク (2)

  • Phactory : Django: context_processorsの使い方

    Djangoには、テンプレートファイル内でのみ利用できるテンプレート変数と、グローバル変数のように、どのテンプレートファイルからも利用できるテンプレート変数も存在しています。 そのようなグローバル変数的なテンプレート変数のことをcontext_processorと呼びます。settings.pyにて、TEMPLATE_CONTEXT_PROCESSORS変数に、テンプレート変数を返すメソッドを登録しておくと、どのビューからでも当該変数をコンテキストに追加することが可能となります。 $ emacs settings.py TEMPLATE_CONTEXT_PROCESSORS = ( "hogeapp.context_processors.user_name", ..., ) $ emacs hogeapp/context_processors.py def user_name(reques

    ideo
    ideo 2010/11/05
    Djangoのcontext_processorsの使い方説明エントリーだけれども、KayFrameworkで使用しているJinja2でも同じ仕組みが使えるので参考になる。
  • Jinja | The Pallets Projects

    Jinja2 is a full-featured template engine for Python. It has full unicode support, an optional integrated sandboxed execution environment, widely used and BSD licensed. Jinja is Beautiful {% extends "layout.html" %} {% block body %} <ul> {% for user in users %} <li><a href="{{ user.url }}">{{ user.username }}</a></li> {% endfor %} </ul> {% endblock %} And PowerfulJinja2 is one of the most used tem

    Jinja | The Pallets Projects
    ideo
    ideo 2010/10/07
    テンプレートエンジン Jinja2リファレンスマニュアル
  • 1