1
0
postdoc/lib/handlebars_renderer.rb

18 lines
371 B
Ruby
Raw Normal View History

2020-12-06 20:49:03 +01:00
class HandlebarsRenderer
attr_reader :handlebars
def initialize
@handlebars = Handlebars::Handlebars.new
end
def render(template_string, bindings)
template = handlebars.compile(sanitize_template(template_string))
template.call(bindings)
end
private
def sanitize_template(template_string)
template_string.gsub('{{# if', '{{#if')
end
end