Template compilation framework in Ruby
Temple is an abstraction and a framework for compiling templates to pure Ruby. It's all about making it easier to experiment, implement and optimize template languages. If you're interested in implementing your own template language, or anything else related to the internals of a template engine: You've come to the right place.
Have a look around, and if you're still wondering: Ask on the mailing list and we'll try to do our best. In fact, it doesn't have to be related to Temple at all. As long as it has something to do with template languages, we're interested: .
Temple is built on a theory that every template consists of three elements:
The goal of a template engine is to take the template and eventually compile it into the core abstraction:
[:multi,
[:static, "Hello "],
[:dynamic, "@user.name"],
[:static, "!\n"],
[:code, "if @user.birthday == Date.today"],
[:static, "Happy birthday!"],
[:code, "end"]]
Then you can apply some optimizations, feed it to Temple and it generates fast Ruby code for you:
_buf = []
_buf Render a file
MyTemplate.new { "String" }.render # => Render a string
You need at least Ruby 1.9.3 to work with Temple. Temple is published as a Ruby Gem which can be installed as following:
$ gem install temple
Thanks to _why for creating an excellent template engine (Markaby) which is quite slow. That's how I started experimenting with template engines in the first place.
I also owe Ryan Davis a lot for his excellent projects ParserTree, RubyParser, Ruby2Ruby and SexpProcessor. Temple is heavily inspired by how these tools work.
No open issues yet, or sync has not completed.