Beispiel #1
0
def templatevars(t):
    """Will return the template variables...
    """
    tag_and_vals = []
    txt = re.sub(r'{#.*?#}', '', t)
    tag_and_vals += re.findall(r'{(?:%|{).*?(?:}|%)}', txt)
    return nest(tag_and_vals)
Beispiel #2
0
def main():
    """cli entry point.
    """
    template = open(sys.argv[1]).read()
    template = re.sub(r'TEMPLATEVARS:.*?:TEMPLATEVARS', "", template)
    txt = repr(nest(tokenize(template)))
    txt = txt.replace('{% end-program %}', '</pre>:TEMPLATEVARS' + '<br>' * 5)
    txt = txt.replace('{% -program None %} ==> []', '')
    # txt = re.sub(r'{%\s*load.*?%}', '', txt)
    txt = 'TEMPLATEVARS:<pre>' + txt
    print txt
Beispiel #3
0
def render(txt):
    r = Render(nest(tokenize(txt)))
    r.render()
    return r.value()