Ejemplo n.º 1
0
                def render(self, context):
                    resolved_vars = [
                        var.resolve(context) for var in self.vars_to_resolve
                    ]
                    if takes_context:
                        args = [context] + resolved_vars
                    else:
                        args = resolved_vars

                    dict = func(*args)

                    if not getattr(self, 'nodelist', False):
                        from google.appengine._internal.django.template.loader import get_template, select_template
                        if not isinstance(
                                file_name,
                                basestring) and is_iterable(file_name):
                            t = select_template(file_name)
                        else:
                            t = get_template(file_name)
                        self.nodelist = t.nodelist
                    new_context = context_class(dict,
                                                autoescape=context.autoescape)
                    # Copy across the CSRF token, if present, because inclusion
                    # tags are often used for forms, and we need instructions
                    # for using CSRF protection to be as simple as possible.
                    csrf_token = context.get('csrf_token', None)
                    if csrf_token is not None:
                        new_context['csrf_token'] = csrf_token
                    return self.nodelist.render(new_context)
Ejemplo n.º 2
0
 def __init__(self, template_path):
     try:
         t = get_template(template_path)
         self.template = t
     except:
         if settings.TEMPLATE_DEBUG:
             raise
         self.template = None
Ejemplo n.º 3
0
 def __init__(self, template_path):
     try:
         t = get_template(template_path)
         self.template = t
     except:
         if settings.TEMPLATE_DEBUG:
             raise
         self.template = None
Ejemplo n.º 4
0
 def render(self, context):
     try:
         template_name = self.template_name.resolve(context)
         t = get_template(template_name)
         return t.render(context)
     except:
         if settings.TEMPLATE_DEBUG:
             raise
         return ''
Ejemplo n.º 5
0
 def render(self, context):
     try:
         template_name = self.template_name.resolve(context)
         t = get_template(template_name)
         return t.render(context)
     except:
         if settings.TEMPLATE_DEBUG:
             raise
         return ''
Ejemplo n.º 6
0
 def get_parent(self, context):
     if self.parent_name_expr:
         self.parent_name = self.parent_name_expr.resolve(context)
     parent = self.parent_name
     if not parent:
         error_msg = "Invalid template name in 'extends' tag: %r." % parent
         if self.parent_name_expr:
             error_msg += " Got this from the '%s' variable." % self.parent_name_expr.token
         raise TemplateSyntaxError(error_msg)
     if hasattr(parent, 'render'):
         return parent # parent is a Template object
     return get_template(parent)
Ejemplo n.º 7
0
 def get_parent(self, context):
     if self.parent_name_expr:
         self.parent_name = self.parent_name_expr.resolve(context)
     parent = self.parent_name
     if not parent:
         error_msg = "Invalid template name in 'extends' tag: %r." % parent
         if self.parent_name_expr:
             error_msg += " Got this from the '%s' variable." % self.parent_name_expr.token
         raise TemplateSyntaxError(error_msg)
     if hasattr(parent, 'render'):
         return parent # parent is a Template object
     return get_template(parent)
Ejemplo n.º 8
0
                def render(self, context):
                    resolved_vars = [var.resolve(context) for var in self.vars_to_resolve]
                    if takes_context:
                        args = [context] + resolved_vars
                    else:
                        args = resolved_vars

                    dict = func(*args)

                    if not getattr(self, 'nodelist', False):
                        from google.appengine._internal.django.template.loader import get_template, select_template
                        if not isinstance(file_name, basestring) and is_iterable(file_name):
                            t = select_template(file_name)
                        else:
                            t = get_template(file_name)
                        self.nodelist = t.nodelist
                    new_context = context_class(dict, autoescape=context.autoescape)
                    # Copy across the CSRF token, if present, because inclusion
                    # tags are often used for forms, and we need instructions
                    # for using CSRF protection to be as simple as possible.
                    csrf_token = context.get('csrf_token', None)
                    if csrf_token is not None:
                        new_context['csrf_token'] = csrf_token
                    return self.nodelist.render(new_context)