This post originated from an RSS feed registered with Python Buzz
by Phillip Pearson.
Original Post: Miniature Java template compiler
Feed Title: Second p0st
Feed URL: http://www.myelin.co.nz/post/rss.xml
Feed Description: Tech notes and web hackery from the guy that brought you bzero, Python Community Server, the Blogging Ecosystem and the Internet Topic Exchange
Why are there so many Java templating engines, when JSP is right there for you to use? I'm starting to understand -- JSP has a strange 'feel'. It should be possible to do FreeEnergy with the include directive though. Hmm.
The start of an experiment:
#!/usr/local/bin/python
import sys
html = open(sys.argv[1]).read()
while 1:
x = html.split('<%', 1)
if x[0]:
print 'out.write("%s");' % x[0].replace('\\', '\\\\').replace('"', '\"').replace('\n', '\\n')
if len(x) == 1: break
code, html = x[1].split('%>', 1)
if code:
if code[0] == '=': code = 'out.write(%s)' % code[1:]
print code