Class: H2o::Tags::With
Constant Summary collapse
Instance Method Summary collapse
-
#initialize(parser, argstring) ⇒ With
constructor
A new instance of With.
- #render(context, stream) ⇒ Object
Constructor Details
#initialize(parser, argstring) ⇒ With
Returns a new instance of With.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/h2o/tags/with.rb', line 6 def initialize(parser, argstring) @body = parser.parse(:endwith) if argstring =~ Syntax @name = $1.to_sym @shortcut = $2.to_sym else raise SyntaxError, "Invalid with syntax " end end |
Instance Method Details
#render(context, stream) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/h2o/tags/with.rb', line 17 def render(context, stream) object = context.resolve(@name) context.stack do context[@shortcut] = object @body.render(context, stream) end end |