コード例 #1
0
ファイル: debug.py プロジェクト: 0xmilk/appscale
 def render(self, context):
     try:
         output = self.filter_expression.resolve(context)
         output = localize(output)
         output = force_unicode(output)
     except TemplateSyntaxError, e:
         if not hasattr(e, 'source'):
             e.source = self.source
         raise
コード例 #2
0
 def render(self, context):
     try:
         output = self.filter_expression.resolve(context)
         output = localize(output)
         output = force_unicode(output)
     except TemplateSyntaxError, e:
         if not hasattr(e, 'source'):
             e.source = self.source
         raise
コード例 #3
0
ファイル: __init__.py プロジェクト: 0xmilk/appscale
def _render_value_in_context(value, context):
    """
    Converts any value to a string to become part of a rendered template. This
    means escaping, if required, and conversion to a unicode object. If value
    is a string, it is expected to have already been translated.
    """
    value = localize(value)
    value = force_unicode(value)
    if (context.autoescape and not isinstance(value, SafeData)) or isinstance(value, EscapeData):
        return escape(value)
    else:
        return value
コード例 #4
0
def _render_value_in_context(value, context):
    """
    Converts any value to a string to become part of a rendered template. This
    means escaping, if required, and conversion to a unicode object. If value
    is a string, it is expected to have already been translated.
    """
    value = localize(value)
    value = force_unicode(value)
    if (context.autoescape and not isinstance(value, SafeData)) or isinstance(value, EscapeData):
        return escape(value)
    else:
        return value
コード例 #5
0
 def render(self, context):
     try:
         output = self.filter_expression.resolve(context)
         output = localize(output)
         output = force_unicode(output)
     except TemplateSyntaxError as e:
         if not hasattr(e, 'source'):
             e.source = self.source
         raise
     except UnicodeDecodeError:
         return ''
     if (context.autoescape and not isinstance(output, SafeData)) or isinstance(output, EscapeData):
         return escape(output)
     else:
         return output