Sha256: e8c5f1656d62d7c02706a675c55fe7194a4579a90f1e9903b8c07fa2f79585cc
Contents?: true
Size: 890 Bytes
Versions: 1
Compression:
Stored size: 890 Bytes
Contents
module Cutaneous class Template attr_accessor :loader, :lexer, :path def initialize(lexer) @lexer = lexer end def compiler @compiler ||= Compiler.new(lexer, loader) end def render(context) context.__loader = loader context.instance_eval(&template_proc) end def convert(to_syntax) lexer.convert(to_syntax) end def template_proc @template_proc ||= eval(template_proc_src, nil, path || "(cutaneous)").tap do |proc| @lexer = nil # release any memory used by the lexer, we don't need it anymore end end def template_proc_src "lambda { |context| self.__buf = __buf = ''; #{script}; __buf.to_s }" end def script compiler.script end def block_order compiler.block_order end def block(block_name) compiler.block(block_name) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cutaneous-0.1.5 | lib/cutaneous/template.rb |