Class: Ruty::Tags::Include

Inherits:
Ruty::Tag show all
Defined in:
lib/ruty/tags/inclusion.rb

Overview

simple include tag. just includes another template at the current position. (for header/footer inclusion for example, although it’s better to use extends in combination with some blocks)

Instance Method Summary collapse

Constructor Details

#initialize(parser, argstring) ⇒ Include

Returns a new instance of Include.



15
16
17
18
19
20
21
22
23
# File 'lib/ruty/tags/inclusion.rb', line 15

def initialize parser, argstring
  if not argstring =~ /^("')(.*?)\1$/
    parser.fail('include takes exactly one argument which must be ' +
                'an hardcoded string')
  end

  # load given template using the load_local function of the parser
  @nodelist = parser.load_local(argstring[1...-1])
end

Instance Method Details

#render_node(context, stream) ⇒ Object



25
26
27
# File 'lib/ruty/tags/inclusion.rb', line 25

def render_node context, stream
  @nodelist.render_node(context, stream)
end