Class: Ruty::Tags::Capture
- Inherits:
-
Ruty::Tag
- Object
- Datastructure::Node
- Ruty::Tag
- Ruty::Tags::Capture
- Defined in:
- lib/ruty/tags/capture.rb
Overview
Ruty Capture Tag
- Author
-
Armin Ronacher
Copyright © 2006 by Armin Ronacher
You can redistribute it and/or modify it under the terms of the BSD license.
Instance Method Summary collapse
-
#initialize(parser, argstring) ⇒ Capture
constructor
A new instance of Capture.
- #render_node(context, stream) ⇒ Object
Constructor Details
#initialize(parser, argstring) ⇒ Capture
Returns a new instance of Capture.
11 12 13 14 15 16 17 18 |
# File 'lib/ruty/tags/capture.rb', line 11 def initialize parser, argstring if not argstring =~ /^as\s+([a-zA-Z_][a-zA-Z0-9_]*)$/ parser.fail('syntax for capture tag: {% capture as <variable> %}') end @name = $1.to_sym @nodelist = parser.parse_until { |n, a| n == :endcapture } end |
Instance Method Details
#render_node(context, stream) ⇒ Object
20 21 22 23 24 |
# File 'lib/ruty/tags/capture.rb', line 20 def render_node context, stream substream = '' @nodelist.render(context, substream) context[@name] = substream end |