Search code examples
rubytemplate-engine

Ruby template engine that looks like ruby syntax


I believe i've seen a template engine that uses ruby-like syntax, such as:

some_variable = 'bla bla'
res = div id:'yay' {
  button onclick: 'test()', class: 'btn btn-primary btn-xs'
  p some_variable
}
# generates: 
# <div id='yay'>
#   <button onclick='test()' class='btn btn-primary btn-xs'></button>
#   <p>bla bla</p>
# </div>

but i forgot the name of this template engine, anyone know the name of this template engine?


Solution

  • This is just a standard implementation of the Builder design pattern in a language with first-class and higher-order subroutines. There are many such implementations in Ruby, including XML::Builder, Markaby, Erector and countless others.