https://github.com/KeenS/zenekindarl.git
git clone 'https://github.com/KeenS/zenekindarl.git'
(ql:quickload :zenekindarl)
Expected to be a fast, flexible, extensible, low memory usage, async, concurrent template engine.
Like this
(render "Hello {{var name}}!!"
:name "κeen")
(let ((renderer (compile-template-string :stream "Hello {{var name}}!!")))
(funcall renderer *standard-output* :name "κeen"))
.
For more information, see docstring
Zenekindarl perform x16 as fast as a template engine in Python in the following instant benchmark.
Template engines | Time[sec] ———————|———- Zenekindarl, SBCL 1.1.8 | 1.365 Jinja2, Python 2.7.5 | 24.07
The benchmark code for Zenekindarl:
> (time
(with-open-file (out #P"~/Desktop/out" :direction :output :if-exists :supersede)
(let ((fun (zenekindarl:compile-template-string :stream "Hello {{var name}}!!")))
(loop repeat 1000000
do (funcall fun out :name "κeen")))))
Evaluation took:
1.625 seconds of real time
1.364707 seconds of total run time (1.302198 user, 0.062509 system)
[ Run times consist of 0.042 seconds GC time, and 1.323 seconds non-GC time. ]
84.00% CPU
1 form interpreted
3 lambdas converted
3,265,218,807 processor cycles
528,706,464 bytes consed
The benchmark code for a template engine in Python:
$ cat te.py
from jinja2 import Template
template = Template( u'Hello {{ name }}!!' )
f = open( 'out', 'w' )
for i in range( 1000000 ):
f.write( template.render( name=u'κeen' ).encode( 'utf-8' ) )
$ time python te.py
real 0m25.612s
user 0m24.069s
sys 0m0.190s
variables will be HTML escaped
{{var foo}}
{{repeat 10}}hello{{endrepeat}}
{{repeat n as i}}<li>{{var i}}th item</li>{{endrepeat}}
<ol>
{{loop items as item}}
<li>{{var item}}</li>
{{endloop}}
</ol>
{{if new-p}}New{{else}}Old{{endif}}
See code below
<code><pre>
{{insert "snippet.lisp"}}
</pre></code>
<nav>
{{incude "sidebar.tmpl"}}
</nav>
Copyright (c) 2014 κeen