Class: Amrita2::Filters::Join
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #filter_element(de, e) ⇒ Object
-
#initialize(sep) ⇒ Join
constructor
A new instance of Join.
Methods inherited from Base
filter_method, inherited, #parse_filter_a, #|
Constructor Details
#initialize(sep) ⇒ Join
Returns a new instance of Join.
2506 2507 2508 2509 2510 2511 2512 |
# File 'lib/amrita2/template.rb', line 2506 def initialize(sep) @sep = case sep when :br ; "<br />" when :nbsp ; " " else ; sep end end |
Instance Method Details
#filter_element(de, e) ⇒ Object
2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 |
# File 'lib/amrita2/template.rb', line 2514 def filter_element(de, e) a = e.children.dup a.each do |n| case n when Hpricot::CData, Hpricot::Elem e.insert_after(Hpricot::Text.new(@sep), n) unless n == a.last when Hpricot::Text e.insert_after(Hpricot::Text.new(@sep), n) unless n == a.last n.content.strip! n.content.gsub!(/\s*\n\s*/, @sep) end end e end |