lib/hotcell/template.rb in hotcell-0.0.1 vs lib/hotcell/template.rb in hotcell-0.1.0

- old
+ new

@@ -2,28 +2,37 @@ class Template attr_reader :source, :options def self.parse source new source, - commands: Hotcell.commands.keys, - blocks: Hotcell.blocks.keys, - subcommands: Hotcell.subcommands.keys + commands: Hotcell.commands, + blocks: Hotcell.blocks end def initialize source, options = {} - @source = source + @source = Source.wrap(source, options.delete(:file)) @options = options end def syntax - @syntax ||= Parser.new(source, options.slice(:commands, :blocks, :subcommands)).parse + @syntax ||= Parser.new(source, options.slice(:commands, :blocks)).parse end def render context = {} if context.is_a?(Context) syntax.render(context) else - syntax.render(Context.new(context)) + 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