(*args, **kwargs)
return TEMPLATES[tplid].render(kwargs)
Get a rendered template as a string iterator.
    You can use a name, a filename or a template string as first parameter.
    Template rendering arguments can be passed as dictionaries
    or directly (as keyword arguments).
Get a rendered template as a string iterator.
    You can use a name, a filename or a template string as first parameter.
    Template rendering arguments can be passed as dictionaries
    or directly (as keyword arguments).
Get a rendered template as a string iterator . You can use a name a filename or a template string as first parameter . Template rendering arguments can be passed as dictionaries or directly ( as keyword arguments ) .
def template(*args, **kwargs):
    '''
    Get a rendered template as a string iterator.
    You can use a name, a filename or a template string as first parameter.
    Template rendering arguments can be passed as dictionaries
    or directly (as keyword arguments).
    '''
    tpl = args[0] if args else None
    adapter = kwargs.pop('template_adapter', SimpleTemplate)
    lookup = kwargs.pop('template_lookup', TEMPLATE_PATH)
    tplid = (id(lookup), tpl)
    if tplid not in TEMPLATES or DEBUG:
        settings = kwargs.pop('template_settings', {})
        if isinstance(tpl, adapter):
            TEMPLATES[tplid] = tpl
            if settings: TEMPLATES[tplid].prepare(**settings)
        elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl:
            TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings)
        else:
            TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings)
    if not TEMPLATES[tplid]:
        abort(500, 'Template (%s) not found' % tpl)
    for dictarg in args[1:]: kwargs.update(dictarg)
    return TEMPLATES[tplid].render(kwargs)
def template ( * args , * * kwargs ) : tpl = args [ 0 ] if args else None adapter = kwargs . pop ( 'template_adapter' , SimpleTemplate ) lookup = kwargs . pop ( 'template_lookup' , TEMPLATE_PATH ) tplid = ( id ( lookup ) , tpl ) if tplid not in TEMPLATES or DEBUG : settings = kwargs . pop ( 'template_settings' , { } ) if isinstance ( tpl , adapter ) : TEMPLATES [ tplid ] = tpl if settings : TEMPLATES [ tplid ] . prepare ( * * settings ) elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl : TEMPLATES [ tplid ] = adapter ( source = tpl , lookup = lookup , * * settings ) else : TEMPLATES [ tplid ] = adapter ( name = tpl , lookup = lookup , * * settings ) if not TEMPLATES [ tplid ] : abort ( 500 , 'Template (%s) not found' % tpl ) for dictarg in args [ 1 : ] : kwargs . update ( dictarg ) return TEMPLATES [ tplid ] . render ( kwargs )