Commits

Andriy Kornatskyy committed 2d37e06

Added InlineExtension to jinja2 demo.

Comments (0)

Files changed (4)

demos/template/content/templates-jinja2/shared/master.html

                     <h1><a href="{{ path_for('default') }}">My Site</a></h1>
                 </div>
                 <div id="logindisplay">
-                    {% include "shared/snippet/menu-signin.html" %}
-                    {% include "shared/snippet/menu-locale.html" %}
+                    {% inline "shared/snippet/menu-signin.html" %}
+                    {% inline "shared/snippet/menu-locale.html" %}
                 </div>
                 <div id="menucontainer">
-                    {% include "shared/snippet/menu-header.html" %}
+                    {% inline "shared/snippet/menu-header.html" %}
                 </div>
             </div>
             <div id="main">
                 <div id="footer">Version {{ __version__ }}</div>
             </div>
         </div>
-        {% include "shared/snippet/script.html" %}
+        {% inline "shared/snippet/script.html" %}
         {% block script %}{% endblock %}
     </body>
 </html>

demos/template/development.ini

 
 [jinja2]
 auto-reload = False
+inline-preprocessor-fallback = False
 
 [uwsgi]
 wsgi = app:main

demos/template/setup.py

 install_requires = [
     'wheezy.core>=0.1.70',
     'wheezy.caching>=0.1.54',
-    'wheezy.html>=0.1.94',
+    'wheezy.html>=0.1.95',
     'wheezy.http>=0.1.236',
     'wheezy.routing>=0.1.124',
     'wheezy.security>=0.1.36',

demos/template/src/config.py

 elif template_engine == 'jinja2':
     from jinja2 import Environment
     from jinja2 import FileSystemLoader
+    from wheezy.html.ext.jinja2 import InlineExtension
     from wheezy.html.ext.jinja2 import WidgetExtension
     from wheezy.html.ext.jinja2 import WhitespaceExtension
     from wheezy.html.utils import format_value
     from wheezy.web.templates import Jinja2Template
     from public import __version__
-
+    searchpath = ['content/templates-jinja2']
     env = Environment(
-        loader=FileSystemLoader('content/templates-jinja2'),
+        loader=FileSystemLoader(searchpath),
         auto_reload=config.get('jinja2', 'auto-reload'),
         extensions=[
+            InlineExtension(searchpath, config.getboolean(
+                    'jinja2', 'inline-preprocessor-fallback')),
             WidgetExtension,
             WhitespaceExtension
         ])