Render a Cheetah template.

    :rtype: A Python data structure
498732
def render(cheetah_data, saltenv='base', sls='', method='xml', **kws):
    '''
    
    '''
    if not HAS_LIBS:
        return {}

    if not isinstance(cheetah_data, six.string_types):
        cheetah_data = cheetah_data.read()

    if cheetah_data.startswith('#!'):
        cheetah_data = cheetah_data[(cheetah_data.find('\n') + 1):]
    if not cheetah_data.strip():
        return {}

    return six.text_type(Template(cheetah_data, searchList=[kws]))
965742
def render(self, name, value, attrs=None, renderer=None):
        
        context = self.get_context(name, value, attrs)
        return self._render(self.template_name, context, renderer)
1094882
def custom_render_template(template_name_or_list, **context):
    
    response_str = render_template(
        functools.reduce(lambda x, y: x + [os.path.join('custom', y), y],
                         to_list(template_name_or_list), []),
        **context
    )
    if hasattr(g, 'status_code'):
        status_code = g.status_code
    else:
        status_code = 200
    return response_str, status_code
59946
def render(self, context, request=None):
        """"""
        context['component'] = self
        return render_to_string(self.template_name, context, 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')
805368
def _iter_templates():
    

    # pylint: disable=W0406
    # needed for introspection
    import javatools.cheetah
    from Cheetah.Template import Template

    for _, name, _ in iter_modules(__path__):
        __import__("javatools.cheetah." + name)
        found = getattr(getattr(javatools.cheetah, name), name)
        if issubclass(found, Template):
            yield found
622177
def _render(template, callable_, args, data, as_unicode=False):
    """"""

    if as_unicode:
        buf = util.FastEncodingBuffer(as_unicode=True)
    elif template.bytestring_passthrough:
        buf = compat.StringIO()
    else:
        buf = util.FastEncodingBuffer(
                        as_unicode=as_unicode,
                        encoding=template.output_encoding,
                        errors=template.encoding_errors)
    context = Context(buf, **data)
    context._outputting_as_unicode = as_unicode
    context._set_with_template(template)

    _render_context(template, callable_, context, *args,
                            **_kwargs_for_callable(callable_, data))
    return context._pop_buffer().getvalue()
283342
def render(self, template, filename, context={}, filters={}):
        
        filename = os.path.normpath(filename)
        path, file = os.path.split(filename)
        try:
            os.makedirs(path)
        except OSError as exception:
            if exception.errno != errno.EEXIST:
                raise

        path, file = os.path.split(template)
        loader = jinja2.FileSystemLoader(path)
        env = jinja2.Environment(loader=loader, trim_blocks=True, lstrip_blocks=True)
        env.filters.update(filters)
        template = env.get_template(file)
        text = template.render(context)
        with open(filename, 'wt') as f:
            f.write(text)
908347
def render_templates_generator(*files, **template_map):
    
    for path in files:
        if not os.path.isfile(path):
            raise ValueError("Template file %s not found"
                             % os.path.relpath(path))
        else:
            try:
                with codecs.open(path, encoding='utf-8') as f:
                    text = f.read()
                template = JINJA_ENV.from_string(text)
            except jinja2.TemplateSyntaxError as err:
                msg = ("Error rendering jinja2 template for file %s "
                       "on line %s. Error: %s"
                       % (path, err.lineno, err.message))
                raise type(err)(
                    msg, err.lineno, filename=os.path.basename(path))

            result = template.render(**template_map)
            if not result.endswith('\n'):
                result += '\n'
            yield path, result
967047
def _render_template(config_file):
    '''
    
    '''
    dirname, filename = os.path.split(config_file)
    env = jinja2.Environment(loader=jinja2.FileSystemLoader(dirname))
    template = env.get_template(filename)
    return template.render(__grains__)
719231
def template_string(context, template):
    ''
    if not isinstance(context, Context):
        context = Context(context)
    return Template(template).render(context)
62628
def render(template, context=None, **kwargs):
    
    renderer = Renderer()
    return renderer.render(template, context, **kwargs)
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
627382
def render_it(self, *args, **kwargs):
        '''
        
        '''
        kind = kwargs.get('kind', args[0])
        num = kwargs.get('num', args[1] if len(args) > 1 else 6)
        with_tag = kwargs.get('with_tag', False)
        glyph = kwargs.get('glyph', '')

        all_cats = MPost.query_most(kind=kind, num=num).objects()
        kwd = {
            'with_tag': with_tag,
            'router': router_post[kind],
            'glyph': glyph
        }
        return self.render_string('modules/info/list_equation.html',
                                  recs=all_cats,
                                  kwd=kwd)
987681
def render(self, **kwargs):
        """"""
        for name, child in self._children.items():
            child.render(**kwargs)
        return self._template.render(this=self, kwargs=kwargs)
584050
def render_template(self):
        """"""
        self.import_mappings()
        self.create_template()
        if self.description:
            self.set_template_description(self.description)
        self.setup_parameters()
        rendered = self.template.to_json(indent=self.context.template_indent)
        version = hashlib.md5(rendered.encode()).hexdigest()[:8]
        return (version, rendered)
1174053
def templated(template=None, *templates):
    

    def decorator(func):
        @functools.wraps(func)
        def wrapper(*args, **kwargs):
            template_ = template
            if template_ is None:
                template_ = request.endpoint.split('.', 1)[1].replace(
                    '.', '/') + '.html'
            context = func(*args, **kwargs)
            if context is None:
                context = {}
            elif not isinstance(context, dict):
                return context
            return custom_render_template(
                list(chain(to_list(template_), templates)), **context)

        return wrapper

    return decorator