3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/express_templates/compiler.rb', line 3
def compile(template_or_src=nil, &block)
if block
begin
block.source
rescue
raise "block must have source - did you do compile(&:label) ?"
end
end
template, src = _normalize(template_or_src)
expander = Expander.new(template)
compiled = expander.expand(src, &block).map(&:compile)
return Interpolator.transform(compiled.join("+").gsub('"+"', '')).tap do |s|
puts("\n"+template.inspect+"\nSource:\n#{template.try(:source)}\nInterpolated:\n#{s}\n") if ENV['DEBUG'].eql?('true')
end
end
|