diff --git a/lib/ruby-handlebars.rb b/lib/ruby-handlebars.rb index 881a93c..a554942 100644 --- a/lib/ruby-handlebars.rb +++ b/lib/ruby-handlebars.rb @@ -39,11 +39,13 @@ def get_as_helper(name) end def register_partial(name, content) - @partials[name.to_s] = Template.new(self, template_to_ast(content)) + @partials[name.to_s] = { content: content, compiled: nil } end def get_partial(name) - @partials[name.to_s] || raise(::Handlebars::MissingPartial, "Partial \"#{name}\" not registered.") + raise(::Handlebars::MissingPartial, "Partial \"#{name}\" not registered.") unless @partials[name.to_s] + + @partials[name.to_s][:compiled] ||= Template.new(self, template_to_ast(@partials[name.to_s][:content])) end def set_escaper(escaper = nil)