lib/musterb/musterbifier.rb in musterb-0.0.5 vs lib/musterb/musterbifier.rb in musterb-0.0.6
- old
+ new
@@ -1,8 +1,9 @@
class Musterb::Musterbifier
- def initialize(template)
+ def initialize(template, render_partial_template = nil)
@template = template
+ @render_partial_template = render_partial_template || method(:partials_not_implemented)
end
def fetch(tokens)
tokens = tokens.strip.split(".")
last_token = tokens.pop
@@ -28,11 +29,19 @@
"<%= #{fetch match[1..-1]} %>"
when '!'
""
when '.'
"<%== musterb.current %>"
+ when '='
+ raise NotImplementedError, 'Not able to change the mustache delimiter just yet'
+ when '>'
+ "<%= #{@render_partial_template.call(match[1..-1].strip)} %>"
else
"<%== #{fetch match} %>"
end
end
+ end
+
+ def partials_not_implemented(partial)
+ "raise NotImplementedError, 'Don't know how to render partial: #{partial}'"
end
end
\ No newline at end of file