Class: Ruty::Tags::Filter

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

Overview

Ruty Filter 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) ⇒ Filter

Returns a new instance of Filter.


11
12
13
14
15
# File 'lib/ruty/tags/filter.rb', line 11

def initialize parser, argstring
  @filters = parser.parse_arguments('|' + argstring)
  parser.fail('filter tag requires at least on filter') if @filters.empty?
  @nodelist = parser.parse_until { |n, a| n == :endfilter }
end

Instance Method Details

#render_node(context, stream) ⇒ Object


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

def render_node context, stream
  substream = Ruty::Datastructure::OutputStream.new
  @nodelist.render_node(context, substream)
  value = context.apply_filters(substream.to_s, @filters).to_s
  stream << value if not value.empty?
  nil
end