0

I got following ruby example:

require 'tilt'
data = { "site_link" => "http://www.example.com", "title" => "example"}
template = Tilt.new('../templates/test.erb', :default_encoding => 'UTF-8')
output = template.render(data)

puts output

and this is test.erb file:

This should be a link - <%= site_link %>

I can't find a proper syntax to get a value from data hash into template.

BobC
  • 639
  • 5
  • 19

1 Answers1

1

Ok, it looks like I need to specify to tilt that data are a hash. Correct code is:

output = template.render(Hash,data)
BobC
  • 639
  • 5
  • 19