class PrefixLoader:
def __init__(self, prefix_list):
self.prefix_list = prefix_list
def get_template(name):
from django.template.loader import select_template
return select_template(['%s/%s' % (prefix, name) for prefix in self.prefix_list])
tpl.render(Context({}, loader=PrefixLoader(['a', 'b', 'c'])))
The above emulates select_template() for include and extends nodes.{% with foo as x and bar as y and ... %} and {% with foo as x, bar as y, ... %}
{% include "template" with foo as x and bar as y %} and {% include "template" with foo as x, bar as y %}
This is equivalent to {% with ... %}{% include ... %}{% endwith %}.
>>> map(str, smart_split('a, b,c ,d, e ,f', separator_chars=','))
['a', ',', 'b', ',', 'c', ',', 'd', ',', 'e', ',', 'f']
>>> map(str, smart_split('a=1, b=2 , c = 3', separator_chars=',='))
['a', '=', '1', ',', 'b', '=', '2', ',', 'c', '=', '3']
parse_args_and_kwargs(parser, bits, validate_kwarg_names=True, separator=',')
resolve_args_and_kwargs(args, kwargs, context)
parse_context_map(parser, bits, separators=('and', ','), operator='as')
render_with_context_map(renderable, context_map, context)