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
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
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)