Class: Ruty::Tags::Capture

Inherits:
Ruty::Tag show all
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

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