Sha256: 2080b404cce60fd2f3130d197f39c23b8a8aa5640e7b1aed78388fdf4d1c944b
Contents?: true
Size: 930 Bytes
Versions: 2
Compression:
Stored size: 930 Bytes
Contents
module Hotcell class Template attr_reader :source, :options def self.parse source new source, commands: Hotcell.commands, blocks: Hotcell.blocks, escape_tags: Hotcell.escape_tags end def initialize source, options = {} @source = Source.wrap(source, options.delete(:file)) @options = options end def syntax @syntax ||= Parser.new(source, options.slice(:commands, :blocks, :escape_tags)).parse end def render context = {} if context.is_a?(Context) syntax.render(context) else default_context = { helpers: Hotcell.helpers } syntax.render(Context.new(default_context.merge!(context))) end end def render! context = {} if context.is_a?(Context) context.options[:reraise] = true render context else render context.merge(reraise: true) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hotcell-0.3.0 | lib/hotcell/template.rb |
hotcell-0.2.0 | lib/hotcell/template.rb |