Class: Temple::Filters::StaticMerger
- Inherits:
-
Temple::Filter
- Object
- Temple::Filter
- Temple::Filters::StaticMerger
- Defined in:
- lib/temple/filters/static_merger.rb
Overview
Merges several statics into a single static. Example:
[:multi,
[:static, "Hello "],
[:static, "World!"]]
Compiles to:
[:static, "Hello World!"]
Constant Summary
Constants included from Utils
Utils::ESCAPE_HTML, Utils::ESCAPE_HTML_PATTERN
Instance Attribute Summary
Attributes included from Mixins::Options
Instance Method Summary collapse
Methods included from Mixins::Options
Methods included from Mixins::ControlFlowDispatcher
#on_block, #on_case, #on_cond, #on_if
Methods included from Mixins::EscapeDispatcher
Methods included from Mixins::CoreDispatcher
Methods included from Mixins::CompiledDispatcher
Methods included from Utils
#empty_exp?, #escape_html, #escape_html_safe, #indent_dynamic, #unique_name
Instance Method Details
#on_multi(*exps) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/temple/filters/static_merger.rb', line 16 def on_multi(*exps) result = [:multi] text = nil exps.each do |exp| if exp.first == :static if text text << exp.last else text = exp.last.dup result << [:static, text] end else result << compile(exp) text = nil unless exp.first == :newline end end result.size == 2 ? result[1] : result end |