Commits

Andriy Kornatskyy  committed bf619cd

Updated documentation with respect to added support for wheezy.template.

  • Participants
  • Parent commits 1490613

Comments (0)

Files changed (6)

 * `Jinja2 Templates <http://jinja.pocoo.org>`_
 * `Mako Templates <http://www.makotemplates.org>`_
 * `Tenjin Templates <http://www.kuwata-lab.com/tenjin/>`_
+* `Wheezy Templates <http://pypi.python.org/pypi/wheezy.template/>`_
 
 It is optimized for performance, well tested and documented.
 
     $ virtualenv env
     $ env/bin/easy_install wheezy.html
 
-If you would like take a benefit of template preprocessing for Mako
-or Tenjin engines specify extra requirements::
+If you would like take a benefit of template preprocessing for Mako, Jinja2,
+Tenjin or Wheezy.Template engines specify extra requirements::
 
-    $ env/bin/easy_install wheezy.html[mako]
-    $ env/bin/easy_install wheezy.html[tenjin]
+    $ env/bin/easy_install wheezy.html[jinja2]
+    $ env/bin/easy_install wheezy.html[wheezy.template]
 
 If you run into any issue or have comments, go ahead and add on
 `bitbucket`_.

File doc/gettingstarted.rst

     $ env/bin/easy_install wheezy.html
 
 If you would like take a benefit of template preprocessing for
-Jinja2, Mako or Tenjin engines specify extra requirements::
+Jinja2, Mako, Tenjin or Wheezy.Template engines specify extra requirements::
 
     $ env/bin/easy_install wheezy.html[jinja2]
     $ env/bin/easy_install wheezy.html[mako]
     $ env/bin/easy_install wheezy.html[tenjin]
+    $ env/bin/easy_install wheezy.html[wheezy.template]
 
 Develop
 -------

File doc/index.rst

 * `Jinja2 Templates <http://jinja.pocoo.org>`_
 * `Mako Templates <http://www.makotemplates.org>`_
 * `Tenjin Templates <http://www.kuwata-lab.com/tenjin/>`_
+* `Wheezy Templates <http://pypi.python.org/pypi/wheezy.template/>`_
 
 It is optimized for performance, well tested and documented.
 

File doc/modules.rst

 .. automodule:: wheezy.html.ext.mako
    :members:
 
+wheezy.html.ext.template
+------------------------
+
+.. automodule:: wheezy.html.ext.template
+   :members:
+
 wheezy.html.ext.tenjin
 ----------------------
 

File doc/userguide.rst

 * `Jinja2 Templates <http://jinja.pocoo.org>`_
 * `Mako Templates <http://www.makotemplates.org>`_
 * `Tenjin Templates <http://www.kuwata-lab.com/tenjin/>`_
+* `Wheezy Templates <http://pypi.python.org/pypi/wheezy.template/>`_
 
 Jinja2
 ^^^^^^
     )
 
 See :py:mod:`wheezy.html.ext.tenjin` for more examples.
+
+Wheezy Template
+^^^^^^^^^^^^^^^
+
+:ref:`wheezy.html` integration with ``wheezy.template`` is provided via preprocessor
+feature. Here is how to add
+:py:meth:`~wheezy.html.ext.template.WidgetExtension` to your code::
+
+    from wheezy.html.ext.template import WidgetExtension
+    from wheezy.html.utils import html_escape
+    from wheezy.html.utils import format_value
+
+    engine = Engine(
+            ...
+            extensions=[
+                WidgetExtension
+    ])
+    engine.global_vars.update({
+        'format_value': format_value,
+        'h': html_escape
+    })
+
+The only thing
+:py:meth:`~wheezy.html.ext.template.WidgetExtension` does is
+translation of widget code to adequate ``wheezy.template`` code.
+
+Let demonstrate with by example::
+
+    @model.remember_me.checkbox(class_='i')
+
+is translated to the following ``wheezy.template`` code (during template compilation
+phase)::
+
+    <input id="remember-me" name="remember_me" type="checkbox" value="1"
+    @if 'remember_me' in errors:
+     class="error i"
+    @else:
+     class="i"
+    @if model.remember_me:
+     checked="checked"
+    @end
+     />
+
+which effectively renders the HTML at runtime::
+
+    <input id="remember-me" name="remember_me" type="checkbox" value="1" class="i" />
+
+Since widgets also decorate appropriate HTML tags in case of error, ``errors``
+dictionary must be available in ``wheezy.template`` context::
+
+    assert 'errors' in kwargs
+    engine.render('page.html',
+                **kwargs
+    )
+
+See :py:mod:`wheezy.html.ext.template` for more examples.
         'Topic :: Software Development :: Widget Sets',
         'Topic :: Text Processing :: Markup :: HTML'
     ],
-    keywords='html widget markup mako tenjin preprocessor',
+    keywords='html widget markup mako jinja2 tenjin wheezy.template '
+             'preprocessor',
     packages=['wheezy', 'wheezy.html', 'wheezy.html.ext'],
     package_dir={'': 'src'},
     namespace_packages=['wheezy'],