Sha256: 0ebbbed03b20dbddc06b14b3d4d91d0694d5a6f87d065f029c7e0b8a52e55b3b
Contents?: true
Size: 955 Bytes
Versions: 5
Compression:
Stored size: 955 Bytes
Contents
module HealthDataStandards module Export module TemplateHelper attr_accessor :template_format def template_root File.join(File.dirname(__FILE__), '..', '..', '..', 'templates') end def template(template_name) File.read(File.join(template_root, "#{template_name}.#{self.template_format}.erb")) end def partial(partial_name) template("_#{partial_name}") end def render(params) #binding.pry erb = nil if params[:template] erb = template(params[:template]) elsif params[:partial] erb = partial(params[:partial]) end locals = params[:locals] locals ||= {} rendering_context = RenderingContext.new(locals) rendering_context.template_format = self.template_format eruby = Erubis::EscapedEruby.new(erb) eruby.result(rendering_context.my_binding) end end end end
Version data entries
5 entries across 5 versions & 1 rubygems