%! from staticfiles.storage import staticfiles_storage from pipeline_mako import compressed_css, compressed_js from django.utils.translation import get_language_bidi from mako.exceptions import TemplateLookupException from microsite_configuration import microsite %> <%def name='url(file, raw=False)'><% try: url = staticfiles_storage.url(file) except: url = file %>${url}${"?raw" if raw else ""}%def> <%def name='css(group, raw=False)'> <% rtl_group = '{}-rtl'.format(group) if get_language_bidi() and rtl_group in settings.PIPELINE_CSS: group = rtl_group %> % if settings.FEATURES['USE_DJANGO_PIPELINE']: ${compressed_css(group, raw=raw)} % else: % for filename in settings.PIPELINE_CSS[group]['source_filenames']: % endfor %endif %def> <%def name='js(group)'> % if settings.FEATURES['USE_DJANGO_PIPELINE']: ${compressed_js(group)} % else: % for filename in settings.PIPELINE_JS[group]['source_filenames']: % endfor %endif %def> ## A language-direction indicator, suitable for use in class="" attributes, ## for example: ## ##
## <%def name="dir_rtl()"><% return 'rtl' if get_language_bidi() else 'ltr' %>%def> <%def name="include(path)"><% from django.template.loaders.filesystem import _loader source, template_path = _loader.load_template_source(path) %>${source}%def> <%def name="require_module(module_name, class_name)"> %def> <%def name="optional_include_mako(file, with_microsite=False)"><% # http://stackoverflow.com/q/21219531 if with_microsite: file = microsite.get_template_path(file) try: tmpl = self.get_template(file) except TemplateLookupException: pass else: tmpl.render_context(context) %>%def>