view examples/transform/run.py @ 192:cda3bdfc19ed

Expression evaluation now differentiates between undefined variables and variables that are defined but set to `None`.
author cmlenz
date Wed, 23 Aug 2006 17:49:14 +0000
parents 9cf42fb6b21e
children 24757b771651
line wrap: on
line source
#!/usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys

from markup.input import HTMLParser
from markup.template import Context, Template

def transform(html_filename, tmpl_filename):
    tmpl_fileobj = open(tmpl_filename)
    tmpl = Template(tmpl_fileobj, tmpl_filename)
    tmpl_fileobj.close()

    html_fileobj = open(html_filename)
    html = HTMLParser(html_fileobj, html_filename)
    print tmpl.generate(Context(input=html)).render('xhtml')
    html_fileobj.close()

if __name__ == '__main__':
    basepath = os.path.dirname(os.path.abspath(__file__))
    tmpl_filename = os.path.join(basepath, 'template.xml')
    html_filename = os.path.join(basepath, 'index.html')
    transform(html_filename, tmpl_filename)
Copyright (C) 2012-2017 Edgewall Software