gist: 1067 Download_button fork
public
Public Clone URL: git://gist.github.com/1067.git
renderst.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env python
# earl, 2008-07-22
from __future__ import with_statement
import stringtemplate3, simplejson, sys
 
def main():
    with open(sys.argv[1]) as template_file:
        template = stringtemplate3.StringTemplate(template_file.read())
        template.attributes = simplejson.load(sys.stdin)
        sys.stdout.write(unicode(template).encode('utf-8'))
        sys.stdout.flush()
 
if __name__ == '__main__':
    if len(sys.argv) != 2:
        from sys import stderr as err
        print >> err, 'Usage: %s template' % (sys.argv[0])
        print >> err, 'Renders JSON data from stdin through template to stdout.'
        sys.exit(64)
    main()

Owner

chl

Fork Of

Revisions