# HG changeset patch # User cmlenz # Date 1152816746 0 # Node ID 8d6bee631a58945dee8888bf350f874b433c5a2f # Parent 46fed54f23cd9ad1daa05f6429f8a02db9f4e8e7 Added SimpleTAL example to benchmark. diff --git a/examples/bench/run.py b/examples/bench/run.py --- a/examples/bench/run.py +++ b/examples/bench/run.py @@ -1,7 +1,7 @@ from cgi import escape import os +from StringIO import StringIO import sys -import time import timeit __all__ = ['markup', 'clearsilver', 'django', 'kid'] @@ -81,6 +81,25 @@ print template return render +def simpletal(dirname): + from simpletal import simpleTAL, simpleTALES + fileobj = open(os.path.join(dirname, 'base.html')) + base = simpleTAL.compileHTMLTemplate(fileobj) + fileobj.close() + fileobj = open(os.path.join(dirname, 'template.html')) + template = simpleTAL.compileHTMLTemplate(fileobj) + fileobj.close() + def render(): + ctxt = simpleTALES.Context() + ctxt.addGlobal('base', base) + ctxt.addGlobal('title', 'Just a test') + ctxt.addGlobal('user', 'joe') + ctxt.addGlobal('items', ['Number %d' % num for num in range(1, 15)]) + buf = StringIO() + template.expand(ctxt, buf) + return buf.getvalue() + return render + def run(engines): basepath = os.path.abspath(os.path.dirname(__file__)) for engine in engines: diff --git a/examples/bench/simpletal/base.html b/examples/bench/simpletal/base.html new file mode 100644 --- /dev/null +++ b/examples/bench/simpletal/base.html @@ -0,0 +1,15 @@ + + +

+ Hello, name +

+ + + +
+ + + + diff --git a/examples/bench/simpletal/template.html b/examples/bench/simpletal/template.html new file mode 100644 --- /dev/null +++ b/examples/bench/simpletal/template.html @@ -0,0 +1,28 @@ + + + + Title + + +
+ +
+ +
+
+ me +
+
+ world +
+ +

Loop

+ + +
+ +