Skip to content

Commit

Permalink
Added a test for Jinja2 global objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
miracle2k committed Aug 22, 2011
1 parent edbc0f2 commit 49184b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Register a Jinja2 global object with a Coffin library object.
"""

def hello_func(name):
return u"Hello %s" % name

from coffin.template import Library
register = Library()
register.object('hello', hello_func)
9 changes: 9 additions & 0 deletions tests/test_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ def test_nodes_and_extensions():
assert Template('{% load django_tags %}a{% foo_coffin %}b').render(Context()) == 'a{foo}b'


def test_objects():
"""For coffin, global objects can be registered.
"""
from coffin.common import env

# Jinja2 global objects, loaded from a Coffin library
assert env.from_string('{{ hello("John") }}').render() == 'Hello John'


def test_filters():
"""Test availability of registered filters.
"""
Expand Down

0 comments on commit 49184b7

Please sign in to comment.