lib/rake/funnel/support/template_engine.rb in rake-funnel-0.3.2.pre vs lib/rake/funnel/support/template_engine.rb in rake-funnel-0.4.0.pre

- old
+ new

@@ -1,26 +1,30 @@ -require 'erb' - -module Rake::Funnel::Support - class TemplateEngine - class << self - def render(template, filename = nil, binding = nil) - render = ERB.new(replace_at_markers(template), nil, '%<>') - render.filename = filename - render.result(binding || top_level_binding) - end - - private - def replace_at_markers(template) - tags = /(@\w[\w\.]+\w@)/ - - (template || '').gsub(tags) do |match| - "<%= #{match[1...-1]} %>" - end - end - - def top_level_binding - TOPLEVEL_BINDING.dup - end - end - end -end +require 'erb' + +module Rake + module Funnel + module Support + class TemplateEngine + class << self + def render(template, filename = nil, binding = nil) + render = ERB.new(replace_at_markers(template), nil, '%<>') + render.filename = filename + render.result(binding || top_level_binding) + end + + private + def replace_at_markers(template) + tags = /(@\w[\w\.]+\w@)/ + + (template || '').gsub(tags) do |match| + "<%= #{match[1...-1]} %>" + end + end + + def top_level_binding + TOPLEVEL_BINDING.dup + end + end + end + end + end +end