Sha256: f738bf258bd076230a39fb26f895445d53e9855c93cb9f6815aae0b929f4a9ae
Contents?: true
Size: 695 Bytes
Versions: 10
Compression:
Stored size: 695 Bytes
Contents
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
Version data entries
10 entries across 10 versions & 1 rubygems