from jinja.filters import FILTERS as DEFAULT_FILTERS
from jinja.tests import TESTS as DEFAULT_TESTS
from jinja.utils import debug_helper, safe_range, generate_lorem_ipsum, \
- watch_changes
+ watch_changes, render_included
__all__ = ['DEFAULT_FILTERS', 'DEFAULT_TESTS', 'DEFAULT_NAMESPACE']
'range': safe_range,
'debug': debug_helper,
'lipsum': generate_lorem_ipsum,
- 'watchchanges': watch_changes
+ 'watchchanges': watch_changes,
+ 'renderincluded': render_included
}
watch_changes.jinja_context_callable = True
+def render_included(env, context, template_name):
+ """
+ Works like djangos {% include %} tag. It doesn't include the
+ template but load it independently and renders it to a string.
+ """
+ #XXX: ignores parent completely!
+ tmpl = env.get_template(template_name)
+ return tmpl.render(context.to_dict())
+render_included.jinja_context_callable = True
+
+
# python2.4 and lower has a bug regarding joining of broken generators.
# because of the runtime debugging system we have to keep track of the
# number of frames to skip. that's what RUNTIME_EXCEPTION_OFFSET is for.