def _instrumented_test_render(self, *args, **data): """ An instrumented Template render method, providing a signal that can be intercepted by the test system Client """ with _MAKO_LOCK: def mako_callable_(context, *args, **kwargs): template_rendered.send(sender=self, template=self, context=context) return self.original_callable_[-1](context, *args, **kwargs) if hasattr(self, 'original_callable_'): self.original_callable_.append(self.callable_) else: self.original_callable_ = [self.callable_] self.callable_ = mako_callable_ try: response = runtime._render(self, self.original_callable_[-1], args, data) finally: self.callable_ = self.original_callable_.pop() return response
def render_unicode(self, *args, **data): """render the output of this template as a unicode object.""" return runtime._render(self, self.callable_, args, data, as_unicode=True)
def render(self, *args, **data): """render the output of this template as a string. if the template specifies an output encoding, the string will be encoded accordingly, else the output is raw (raw output uses cStringIO and can't handle multibyte characters). a Context object is created corresponding to the given data. Arguments that are explictly declared by this template's internal rendering method are also pulled from the given *args, **data members.""" return runtime._render(self, self.callable_, args, data)
def render_async(self, *args, **data): """Render the output of this template as a unicode string. This is a coroutine. """ return runtime._render(self, self.callable_, args, data, as_unicode=True)
def render_unicode(self, *args, **data): """Render the output of this template as a unicode object. This will only work if the event loop is not running. """ coro = runtime._render(self, self.callable_, args, data, as_unicode=True) return asyncio.get_event_loop().run_until_complete(coro)
def _instrumented_test_render(self, *args, **data): """ An instrumented Template render method, providing a signal that can be intercepted by the test system Client """ def mako_callable_(context, *args, **kwargs): template_rendered.send(sender=self, template=self, context=context) return self.original_callable_(context, *args, **kwargs) self.original_callable_ = self.callable_ self.callable_ = mako_callable_ response = runtime._render(self, self.original_callable_, args, data) self.callable_ = self.original_callable_ return response
def render(self, *args, **data): """Render the output of this template as a string. If the template specifies an output encoding, the string will be encoded accordingly, else the output is raw (raw output uses `cStringIO` and can't handle multibyte characters). A :class:`.Context` object is created corresponding to the given data. Arguments that are explicitly declared by this template's internal rendering method are also pulled from the given ``*args``, ``**data`` members. This will only work if the event loop is not running. """ coro = runtime._render(self, self.callable_, args, data) return asyncio.get_event_loop().run_until_complete(coro)
def _instrumented_test_render(self, *args, **data): """ An instrumented Template render method, providing a signal that can be intercepted by the test system Client """ def mako_callable_(context, *args, **kwargs): template_rendered.send(sender=self, template=self, context=context) return self.original_callable_[-1](context, *args, **kwargs) if hasattr(self, 'original_callable_'): self.original_callable_.append(self.callable_) else: self.original_callable_ = [self.callable_] self.callable_ = mako_callable_ try: response = runtime._render(self, self.original_callable_[-1], args, data) finally: self.callable_ = self.original_callable_.pop() return response
def render(self, *args, **data): return runtime._render(self, self.callable_, args, data, as_unicode=True)