Skip to content

Commit

Permalink
- Add includeme function (meant to be used via config.include).
Browse files Browse the repository at this point in the history
- Fix documentation bug related to ``paster create`` reported at
  https://github.com/Pylons/pyramid_jinja2/issues#issue/12
  • Loading branch information
mcdonc committed Jan 3, 2011
1 parent 5311fd6 commit f76f6d0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGES.txt
@@ -1,6 +1,11 @@
Next release
============

- Add ``includeme`` function (meant to be used via ``config.include``).

- Fix documentation bug related to ``paster create`` reported at
https://github.com/Pylons/pyramid_jinja2/issues#issue/12

0.4 (2010-12-16)
================

Expand Down
11 changes: 8 additions & 3 deletions docs/index.rst
Expand Up @@ -15,8 +15,13 @@ active. Both are completely equivalent.

<include package="pyramid_jinja2"/>

#) Call the ``add_renderer`` method of a Configurator in your
application during configuration::
#) Use the ``includeme`` function via ``config.include``::

import pyramid_jinja2
config.include(pyramid_jinja2.includeme)

You can also drive the oxcart by hand instead of either of the above two
ways::

from pyramid_jinja2 import renderer_factory
config.add_renderer('.jinja2', renderer_factory)
Expand Down Expand Up @@ -168,7 +173,7 @@ Creating a Jinja2 ``Pyramid`` Project
After you've got ``pyramid_jinja2`` installed, you can invoke the following
command to create a Jinja2-based Pyramid project::

$ paster create -t bin/paster pyramid_jinja2_starter
$ paster create -t pyramid_jinja2_starter

This is a good way to see a working Pyramid application that uses Jinja2, even
if you wind up not using the result.
Expand Down
3 changes: 3 additions & 0 deletions pyramid_jinja2/__init__.py
Expand Up @@ -103,3 +103,6 @@ def __call__(self, value, system):
return result


def includeme(config):
config.add_renderer('.jinja2', renderer_factory)

10 changes: 10 additions & 0 deletions pyramid_jinja2/tests/test_it.py
Expand Up @@ -249,6 +249,16 @@ def test_render(self):
result = render('helloworld.jinja2', {'a':1})
self.assertEqual(result, u'\nHello föö')

class Test_includeme(unittest.TestCase):
def test_it(self):
from pyramid.interfaces import IRendererFactory
from pyramid_jinja2 import includeme
from pyramid_jinja2 import renderer_factory
config = testing.setUp()
includeme(config)
utility = config.registry.getUtility(IRendererFactory, name='.jinja2')
self.assertEqual(utility, renderer_factory)

class DummyEnvironment(object):
def get_template(self, path):
self.path = path
Expand Down

0 comments on commit f76f6d0

Please sign in to comment.