예제 #1
0
파일: nodes.py 프로젝트: pnhowe/disks
 def as_const(self, eval_ctx=None):
     eval_ctx = get_eval_context(self, eval_ctx)
     if eval_ctx.volatile:
         raise Impossible()
     if eval_ctx.autoescape:
         return Markup(self.data)
     return self.data
예제 #2
0
파일: nodes.py 프로젝트: pnhowe/disks
 def as_const(self, eval_ctx=None):
     eval_ctx = get_eval_context(self, eval_ctx)
     if eval_ctx.volatile:
         raise Impossible()
     expr = self.expr.as_const(eval_ctx)
     if eval_ctx.autoescape:
         return Markup(expr)
     return expr
예제 #3
0
def markup_join(seq):
    """Concatenation that escapes if necessary and converts to unicode."""
    buf = []
    iterator = imap(soft_unicode, seq)
    for arg in iterator:
        buf.append(arg)
        if hasattr(arg, '__html__'):
            return Markup(u'').join(chain(buf, iterator))
    return concat(buf)
예제 #4
0
파일: environment.py 프로젝트: pnhowe/disks
 def __html__(self):
     return Markup(concat(self._body_stream))
예제 #5
0
 async def async_call(self):
     rv = await concat_async(self._stack[self._depth](self._context))
     if self._context.eval_ctx.autoescape:
         rv = Markup(rv)
     return rv
예제 #6
0
 async def async_invoke(self, arguments, autoescape):
     rv = await self._func(*arguments)
     if autoescape:
         rv = Markup(rv)
     return rv
예제 #7
0
파일: ext.py 프로젝트: pnhowe/disks
 def ngettext(__context, __singular, __plural, __num, **variables):
     variables.setdefault('num', __num)
     rv = __context.call(func, __singular, __plural, __num)
     if __context.eval_ctx.autoescape:
         rv = Markup(rv)
     return rv % variables
예제 #8
0
파일: ext.py 프로젝트: pnhowe/disks
 def gettext(__context, __string, **variables):
     rv = __context.call(func, __string)
     if __context.eval_ctx.autoescape:
         rv = Markup(rv)
     return rv % variables
예제 #9
0
 def _invoke(self, arguments, autoescape):
     """This method is being swapped out by the async implementation."""
     rv = self._func(*arguments)
     if autoescape:
         rv = Markup(rv)
     return rv
예제 #10
0
 def __call__(self):
     rv = concat(self._stack[self._depth](self._context))
     if self._context.eval_ctx.autoescape:
         rv = Markup(rv)
     return rv
예제 #11
0
파일: nodes.py 프로젝트: pnhowe/disks
 def as_const(self, eval_ctx=None):
     eval_ctx = get_eval_context(self, eval_ctx)
     return Markup(self.expr.as_const(eval_ctx))