Current File : //usr/share/doc/python-jinja2-2.7.2/html/integration.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>Integration &mdash; Jinja2 2.7.2 documentation</title>
    
    <link rel="stylesheet" href="_static/jinja.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '',
        VERSION:     '2.7.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="top" title="Jinja2 2.7.2 documentation" href="index.html" />
    <link rel="next" title="Switching from other Template Engines" href="switching.html" />
    <link rel="prev" title="Extensions" href="extensions.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="switching.html" title="Switching from other Template Engines"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="extensions.html" title="Extensions"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Jinja2 2.7.2 documentation</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="integration">
<h1>Integration<a class="headerlink" href="#integration" title="Permalink to this headline">¶</a></h1>
<p>Jinja2 provides some code for integration into other tools such as frameworks,
the <a class="reference external" href="http://babel.edgewall.org/">Babel</a> library or your favourite editor for fancy code highlighting.
This is a brief description of whats included.</p>
<p>Files to help integration are available
<a class="reference external" href="https://github.com/mitsuhiko/jinja2/tree/master/ext">here.</a></p>
<div class="section" id="babel-integration">
<span id="id1"></span><h2>Babel Integration<a class="headerlink" href="#babel-integration" title="Permalink to this headline">¶</a></h2>
<p>Jinja provides support for extracting gettext messages from templates via a
<a class="reference external" href="http://babel.edgewall.org/">Babel</a> extractor entry point called <cite>jinja2.ext.babel_extract</cite>.  The Babel
support is implemented as part of the <a class="reference internal" href="extensions.html#i18n-extension"><em>i18n Extension</em></a> extension.</p>
<p>Gettext messages extracted from both <cite>trans</cite> tags and code expressions.</p>
<p>To extract gettext messages from templates, the project needs a Jinja2 section
in its Babel extraction method <a class="reference external" href="http://babel.edgewall.org/wiki/Documentation/messages.html#extraction-method-mapping-and-configuration">mapping file</a>:</p>
<div class="highlight-ini"><div class="highlight"><pre><span class="k">[jinja2: **/templates/**.html]</span>
<span class="na">encoding</span> <span class="o">=</span> <span class="s">utf-8</span>
</pre></div>
</div>
<p>The syntax related options of the <tt class="xref py py-class docutils literal"><span class="pre">Environment</span></tt> are also available as
configuration values in the mapping file.  For example to tell the extraction
that templates use <tt class="docutils literal"><span class="pre">%</span></tt> as <cite>line_statement_prefix</cite> you can use this code:</p>
<div class="highlight-ini"><div class="highlight"><pre><span class="k">[jinja2: **/templates/**.html]</span>
<span class="na">encoding</span> <span class="o">=</span> <span class="s">utf-8</span>
<span class="na">line_statement_prefix</span> <span class="o">=</span> <span class="s">%</span>
</pre></div>
</div>
<p><a class="reference internal" href="extensions.html#jinja-extensions"><em>Extensions</em></a> may also be defined by passing a comma separated list
of import paths as <cite>extensions</cite> value.  The i18n extension is added
automatically.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.7.</span></p>
</div>
<div class="section" id="pylons">
<h2>Pylons<a class="headerlink" href="#pylons" title="Permalink to this headline">¶</a></h2>
<p>With <a class="reference external" href="http://www.pylonshq.com/">Pylons</a> 0.9.7 onwards it&#8217;s incredible easy to integrate Jinja into a
Pylons powered application.</p>
<p>The template engine is configured in <cite>config/environment.py</cite>.  The configuration
for Jinja2 looks something like that:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">jinja2</span> <span class="kn">import</span> <span class="n">Environment</span><span class="p">,</span> <span class="n">PackageLoader</span>
<span class="n">config</span><span class="p">[</span><span class="s">&#39;pylons.app_globals&#39;</span><span class="p">]</span><span class="o">.</span><span class="n">jinja_env</span> <span class="o">=</span> <span class="n">Environment</span><span class="p">(</span>
    <span class="n">loader</span><span class="o">=</span><span class="n">PackageLoader</span><span class="p">(</span><span class="s">&#39;yourapplication&#39;</span><span class="p">,</span> <span class="s">&#39;templates&#39;</span><span class="p">)</span>
<span class="p">)</span>
</pre></div>
</div>
<p>After that you can render Jinja templates by using the <cite>render_jinja</cite> function
from the <cite>pylons.templating</cite> module.</p>
<p>Additionally it&#8217;s a good idea to set the Pylons&#8217; <cite>c</cite> object into strict mode.
Per default any attribute to not existing attributes on the <cite>c</cite> object return
an empty string and not an undefined object.  To change this just use this
snippet and add it into your <cite>config/environment.py</cite>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">config</span><span class="p">[</span><span class="s">&#39;pylons.strict_c&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">True</span>
</pre></div>
</div>
</div>
<div class="section" id="textmate">
<h2>TextMate<a class="headerlink" href="#textmate" title="Permalink to this headline">¶</a></h2>
<p>Inside the <cite>ext</cite> folder at the root of the Jinja2 project there is a bundle for
TextMate that supports syntax highlighting for Jinja1 and Jinja2 for text based
templates as well as HTML.  It also contains a few often used snippets.</p>
</div>
<div class="section" id="vim">
<h2>Vim<a class="headerlink" href="#vim" title="Permalink to this headline">¶</a></h2>
<p>A syntax plugin for <a class="reference external" href="http://www.vim.org/">Vim</a> exists in the Vim-scripts directory as well as the
<cite>ext</cite> folder at the root of the Jinja2 project.  <a class="reference external" href="http://www.vim.org/scripts/script.php?script_id=1856">The script</a> supports Jinja1 and
Jinja2.  Once installed two file types are available <cite>jinja</cite> and <cite>htmljinja</cite>.
The first one for text based templates, the latter for HTML templates.</p>
<p>Copy the files into your <cite>syntax</cite> folder.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><p class="logo"><a href="index.html">
  <img class="logo" src="_static/jinja-small.png" alt="Logo"/>
</a></p>
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Integration</a><ul>
<li><a class="reference internal" href="#babel-integration">Babel Integration</a></li>
<li><a class="reference internal" href="#pylons">Pylons</a></li>
<li><a class="reference internal" href="#textmate">TextMate</a></li>
<li><a class="reference internal" href="#vim">Vim</a></li>
</ul>
</li>
</ul>
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="extensions.html" title="previous chapter">Extensions</a></li>
      <li>Next: <a href="switching.html" title="next chapter">Switching from other Template Engines</a></li>
  </ul></li>
</ul>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="_sources/integration.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy; Copyright 2008, Armin Ronacher.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>
blog

blog

Mostbet (2640)

Mostbet зеркало рабочее – Вход на официальный сайт Мостбет ▶️ ИГРАТЬ Содержимое Мостбет: надежный партнер для ставок Вход на официальный сайт Мостбет Как зарегистрироваться на официальном сайте Мостбет Как найти рабочее зеркало Мостбет Почему игроки ищут рабочие зеркала Мостбет Как найти рабочее зеркало Мостбет Преимущества использования зеркала Мостбет Безопасность и …

Read More »

1win — казино и БК.3867

1win — казино и БК ▶️ ИГРАТЬ Содержимое 1вин: Казино и БК Преимущества и функции 1win Функции 1win: Как начать играть и ставить в 1вин В мире азарта всегда было важно найти надежный и надежный партнера, который обеспечит вам лучшие условия для игры и ставок. В последние годы, 1вин – …

Read More »

1win — зеркало сайта букмекерской конторы 1вин.1431

1win — зеркало сайта букмекерской конторы 1вин ▶️ ИГРАТЬ Содержимое Преимущества использования зеркала 1win Как найти зеркало 1win Шаг 1: Установите браузер Шаг 2: Найдите зеркало 1win Безопасность и надежность зеркала 1win Защита данных Проверка и сертификация Букмекерская контора 1вин является одним из лидеров на рынке азартных игр. Компания была …

Read More »

1win официальный сайт букмекера — Обзор и зеркало для входа.2917

1win официальный сайт букмекера — Обзор и зеркало для входа ▶️ ИГРАТЬ Содержимое 1win Официальный Сайт Букмекера Официальный Сайт 1win Зеркало 1win для Входа Обзор и Зеркало для Входа Преимущества 1вин Зеркало 1вин: почему это не лучший выбор Преимущества и Функции 1вин Функции 1вин: Как Зарегистрироваться и Начать Играть на …

Read More »

казино – Официальный сайт Pin up играть онлайн Зеркало и вход.4032

Пин Ап казино – Официальный сайт Pin up играть онлайн | Зеркало и вход ▶️ ИГРАТЬ Содержимое Пин Ап Казино – Официальный Сайт Играть Онлайн Зеркало и Вход Pin Up Casino – Официальный сайт Описание и функции Pin Up Казино Как играть онлайн и вход в Pin Up Казино Шаги …

Read More »

1win официальный сайт букмекера — Обзор и зеркало для входа.3479

1win официальный сайт букмекера — Обзор и зеркало для входа ▶️ ИГРАТЬ Содержимое 1win Официальный Сайт Букмекера Обзор и Зеркало для Входа Преимущества и Функции 1win Бонусы и Промокоды В мире ставок и азарта 1win является одним из самых популярных букмекеров, предлагающих широкий спектр услуг для игроков. Компания была основана …

Read More »

1win — зеркало сайта букмекерской конторы 1вин.217

1win — зеркало сайта букмекерской конторы 1вин ▶️ ИГРАТЬ Содержимое Преимущества использования зеркала 1win Быстрый доступ к функциональным возможностям Как работает зеркало 1win Преимущества использования зеркала 1win Как использовать зеркало 1win Безопасность и конфиденциальность на зеркале 1win Как зарегистрироваться на зеркале 1win Шаг 2: подтверждение регистрации Уникальные возможности для ставок …

Read More »

1win — ставки на спорт в букмекерской конторе.5832

1win — ставки на спорт в букмекерской конторе ▶️ ИГРАТЬ Содержимое Преимущества использования 1win Как сделать ставку на спорт в 1win Шаг 1: Регистрация Шаг 2: Депозит Шаг 3: Выбор спортсмена Шаг 4: Сделать ставку Возможности для новых игроков Ограничения и условия использования 1win В мире спорта каждый день происходит …

Read More »

1win — казино и БК.6054

1win — казино и БК ▶️ ИГРАТЬ Содержимое 1win: Казино и БК Преимущества и функции 1вин Удобство и доступность Как начать играть и ставить в 1win Шаги для начала игры в казино Шаги для начала ставки на спорт В мире азарта всегда было важно найти надежный и надежный партнера, который …

Read More »

Покердом Официальный Сайт, Вход и Регистрация в онлайн-казино Pokerdom

Покердом Официальный Сайт, Вход и Регистрация в онлайн-казино Pokerdom ▶️ ИГРАТЬ Содержимое Как зарегистрироваться в онлайн-казино Pokerdom Шаги для входа в онлайн-казино Pokerdom Условия и требования для регистрации в онлайн-казино Pokerdom Важно! В наше время интернета и онлайн-игр, когда каждый может найти свою игру, Покердом остается одним из самых популярных …

Read More »