Tilt Pattern Fragments

Is it possible to display fragments of Tilt templates (i.e. without using a template file on disk)?

Background: I would like to make inline template strings in a Ruby CGI program.

+5
source share
1 answer

Yes. You can use any string data:

>> require 'haml'
>> template = Tilt::HamlTemplate.new { "%h1= 'Hello Haml!'" }
=> #<Tilt::HamlTemplate @file=nil ...>
>> template.render
=> "<h1>Hello Haml!</h1>"

See examples in docs

+7
source

All Articles