Class: PageTemplate::FilterCommand
- Inherits:
-
StackableCommand
- Object
- Command
- StackableCommand
- PageTemplate::FilterCommand
- Defined in:
- lib/PageTemplate/commands.rb
Overview
FilterCommand filters its block through a preprocessor
[% filter :processor %]text[% end %]
Instance Attribute Summary
Attributes inherited from Command
Instance Method Summary collapse
- #add(line) ⇒ Object
-
#initialize(filter) ⇒ FilterCommand
constructor
A new instance of FilterCommand.
- #output(namespace = nil) ⇒ Object
Methods inherited from StackableCommand
Methods inherited from Command
Constructor Details
#initialize(filter) ⇒ FilterCommand
Returns a new instance of FilterCommand.
230 231 232 233 234 |
# File 'lib/PageTemplate/commands.rb', line 230 def initialize(filter) @called_as = "filter" @processor = filter @text = [] end |
Instance Method Details
#add(line) ⇒ Object
236 237 238 |
# File 'lib/PageTemplate/commands.rb', line 236 def add(line) @text.push(line) end |
#output(namespace = nil) ⇒ Object
240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/PageTemplate/commands.rb', line 240 def output(namespace=nil) parser = namespace.parser if namespace parser = Parser.recent_parser unless parser namespace ||= parser preprocessor = parser.preprocessor processor = @processor || parser.default_processor text = "" @text.each { |c| text += c.output(namespace) } if preprocessor.respond_to?(processor) preprocessor.send(processor, text) else "[ ValueCommand: unknown preprocessor #{@processor} ]" end end |