Sha256: a3d35488706bdfd835f67fd56ae8037bb92ddeceb17ae036ce7d11bfd54ece6b
Contents?: true
Size: 711 Bytes
Versions: 22
Compression:
Stored size: 711 Bytes
Contents
require 'zafu/compiler' module Zafu class Template def initialize(template, src_helper = nil, compiler = Zafu::Compiler) if template.kind_of?(String) @ast = compiler.new(template) else @ast = compiler.new_with_url(template.path, :helper => src_helper) end end def to_erb(context = {}) @ast.to_erb(context) end def to_ruby(context = {}) src = ::ERB.new("<% __in_erb_template=true %>#{to_erb(context)}", nil, '-').src # Ruby 1.9 prepends an encoding to the source. However this is # useless because you can only set an encoding on the first line RUBY_VERSION >= '1.9' ? src.sub(/\A#coding:.*\n/, '') : src end end end
Version data entries
22 entries across 22 versions & 2 rubygems