Returns the rendered text from a single template file from the
        template loader using the given context data
17424
def render(self, name, context):
        """"""
        if Generator.strict:
            self.env.undefined = TestableUndefined
        else:
            self.env.undefined = Undefined
        template = self.get_template(name)
        return template.render(context)
50318
def template(name, datas)
      file = template_path(name)
      content = File.read(file)

      datas.each do |k, v|
        k = "<%= #{k} %>"
        content = content.gsub(k, v)
      end
      return content
    end
12216
def render_string(self, template_name: str, **kwargs: Any) -> bytes:
        
        # If no template_path is specified, use the path of the calling file
        template_path = self.get_template_path()
        if not template_path:
            frame = sys._getframe(0)
            web_file = frame.f_code.co_filename
            while frame.f_code.co_filename == web_file:
                frame = frame.f_back
            assert frame.f_code.co_filename is not None
            template_path = os.path.dirname(frame.f_code.co_filename)
        with RequestHandler._template_loader_lock:
            if template_path not in RequestHandler._template_loaders:
                loader = self.create_template_loader(template_path)
                RequestHandler._template_loaders[template_path] = loader
            else:
                loader = RequestHandler._template_loaders[template_path]
        t = loader.load(template_name)
        namespace = self.get_template_namespace()
        namespace.update(kwargs)
        return t.generate(**namespace)
90772
def _render(self, context):
        "  "
        if self.template_name:
            t = loader.get_template(self.template_name)
        else:
            t_list = self._get_template_list()
            t = loader.select_template(t_list)

        context.update(self.get_context())
        resp = t.render(context)
        context.pop()
        return resp
551067
def render(template_file, saltenv='base', sls='', context=None, tmplpath=None, **kws):
    '''
    
    '''
    tmp_data = salt.utils.templates.MAKO(template_file, to_str=True,
                    salt=__salt__,
                    grains=__grains__,
                    opts=__opts__,
                    pillar=__pillar__,
                    saltenv=saltenv,
                    sls=sls,
                    context=context,
                    tmplpath=tmplpath,
                    **kws)
    if not tmp_data.get('result', False):
        raise SaltRenderError(tmp_data.get('data',
            'Unknown render error in mako renderer'))
    return six.moves.StringIO(tmp_data['data'])
849772
def render(self, data, accepted_media_type=None, renderer_context=None):
        
        form = data.serializer

        style = renderer_context.get('style', {})
        if 'template_pack' not in style:
            style['template_pack'] = self.template_pack
        style['renderer'] = self

        template_pack = style['template_pack'].strip('/')
        template_name = template_pack + '/' + self.base_template
        template = loader.get_template(template_name)
        context = {
            'form': form,
            'style': style
        }
        return template_render(template, context)
751773
def xgettext(self, template):
        """"""

        cmd = 'xgettext -d django -L Python --keyword=gettext_noop \
            --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code=UTF-8 \
            --output=- -'

        p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        (msg, err) = p.communicate(input=templatize(template))

        if err:
            # dont raise exception, some stuff in stderr are just warmings
            logging.warning(err)

        if XGETTEXT_REENCODES_UTF8:
            return msg.decode('utf-8').encode('iso-8859-1')

        return msg
688833
def render(self, name=None, template=None, context={}):
        ''''

        '''

        if isinstance(template, Template):
            _template = template
        else:
            _template = Template.objects.get(name=name)

        # Maybe cache or save local ?
        response = self.env.from_string(
            _template.content).render(context)

        return response
1150592
def render_to_string(self, template_name, context=None):
        """"""
        # create an empty context if no context was specified
        context = context or {}
        tmpl = self.get_template(template_name)
        # render the template into a unicode string (None means unicode)
        return tmpl. \
            generate(**context). \
            render(self.output_type, encoding=None)
696530
def get_context(template, line, num_lines=5, marker=None):
    '''
    
    '''
    template_lines = template.splitlines()
    num_template_lines = len(template_lines)

    # In test mode, a single line template would return a crazy line number like,
    # 357. Do this sanity check and if the given line is obviously wrong, just
    # return the entire template
    if line > num_template_lines:
        return template

    context_start = max(0, line - num_lines - 1)  # subt 1 for 0-based indexing
    context_end = min(num_template_lines, line + num_lines)
    error_line_in_context = line - context_start - 1  # subtr 1 for 0-based idx

    buf = []
    if context_start > 0:
        buf.append('[...]')
        error_line_in_context += 1

    buf.extend(template_lines[context_start:context_end])

    if context_end < num_template_lines:
        buf.append('[...]')

    if marker:
        buf[error_line_in_context] += marker

    return '---\n{0}\n---'.format('\n'.join(buf))
283370
protected function renderTwig($file, $context = [], $template = null)
    {
        $twig = $this->getTwigEnvironment();

        $template = $twig->loadTemplate($this->findTwigFile($file, $template));

        return $template->render($this->getTwigContext($context));
    }
244795
async def render_template_string(source: str, **context: Any) -> str:
    
    await current_app.update_template_context(context)
    template = current_app.jinja_env.from_string(source)
    return await _render(template, context)
584895
def render_template(content, variables):
    
    fsenc = sys.getfilesystemencoding()

    def to_native(s, encoding='latin-1', errors='strict'):
        if six.PY3:
            if isinstance(s, six.text_type):
                return s
            return str(s, encoding, errors)
        else:
            if isinstance(s, six.text_type):
                return s.encode(encoding, errors)
            return str(s)

    output = Template(
        to_native(content, fsenc)
    ).substitute(variables)
    if isinstance(output, six.text_type):
        output = output.encode(fsenc, 'strict')
    return output
1227955
def render_to_string(self, request, template, context, content_instance=None):
        
        if not content_instance:
            content_instance = PluginContext(request)

        content_instance.update(context)
        return render_to_string(template, content_instance.flatten(), request=request)
296479
def _get_content(self, context):
        
        self._valid_template()
        context.update({
            "csrf_token_value": get_token(self.request)
        })
        return render_to_string(self.get_template_names(), context)
1074828
def message(self):
        
        template_name = self.template_name() if \
            callable(self.template_name) \
            else self.template_name
        return loader.render_to_string(
            template_name, self.get_context(), request=self.request
        )
260420
def render_template(env, html_path, template_filename, context):
    
    template = env.get_template(template_filename)
    rendered_html = template.render(**context)  # pylint: disable=no-member
    html_path.write_text(rendered_html, encoding='utf-8')