Posts tagged template

Simple template transformer

2019-06-11

A simple template transformer demonstrating the concept being used in many template engines like , , etc. Even though this gist doesn’t dive as deep. It is still somewhat helpful in giving an idea of how these things work. It supports the basic js schema like if statements, for loops, switch statements for a bit complex templating. Also nested variables/keys. You can also return instead to remove the from your literal identifiers. But remember that Douglas will hate you. If you want a ruby implementation, is a good place to start. It is extremely light-weight and I believe scales as well. However if you want a lean implementation of that, here it goes. index.html.trb You can try the following in irb/pry.