コード例 #1
0
 def process_template_response(self, request, response):
     if hasattr(response, "template_name"):
         if not isinstance(response.template_name, Template):
             templates = templates_for_device(request,
                                              response.template_name)
             response.template_name = templates
     return response
コード例 #2
0
ファイル: middleware.py プロジェクト: Memode/mezzanine
 def process_template_response(self, request, response):
     if hasattr(response, "template_name"):
         if not isinstance(response.template_name, Template):
             templates = templates_for_device(request,
                 response.template_name)
             response.template_name = templates
     return response
コード例 #3
0
ファイル: middleware.py プロジェクト: n1k0/mezzanine
 def process_template_response(self, request, response):
     """
     Inserts device-specific templates to the template list.
     """
     templates = templates_for_device(request, response.template_name)
     response.template_name = templates
     return response
コード例 #4
0
 def process_template_response(self, request, response):
     """
     Inserts device-specific templates to the template list.
     """
     templates = templates_for_device(request, response.template_name)
     response.template_name = templates
     return response
コード例 #5
0
ファイル: __init__.py プロジェクト: niotech/mezzanine
 def render(self, context):
     if not getattr(self, "nodelist", False):
         try:
             request = context["request"]
         except KeyError:
             t = get_template(name)
         else:
             ts = templates_for_device(request, name)
             t = select_template(ts)
         self.nodelist = t.nodelist
     parts = [template.Variable(part).resolve(context) for part in token.split_contents()[1:]]
     if takes_context:
         parts.insert(0, context)
     result = tag_func(*parts)
     autoescape = context.autoescape
     context = context_class(result, autoescape=autoescape)
     return self.nodelist.render(context)
コード例 #6
0
 def render(self, context):
     if not getattr(self, "nodelist", False):
         try:
             request = context["request"]
         except KeyError:
             t = get_template(name)
         else:
             ts = templates_for_device(request, name)
             t = select_template(ts)
         self.nodelist = t.nodelist
     parts = [template.Variable(part).resolve(context)
              for part in token.split_contents()[1:]]
     if takes_context:
         parts.insert(0, context)
     result = tag_func(*parts)
     autoescape = context.autoescape
     context = context_class(result, autoescape=autoescape)
     return self.nodelist.render(context)