Serializer
class that converts tags to plain text strings.
Registered at :text.
Public Instance methods
call(tag)
Serialize the tag to plain text string.
[show source]
# File lib/forme/transformers/serializer.rb 132 def call(tag) 133 case tag 134 when Tag 135 case tag.type.to_sym 136 when :input 137 case tag.attr[:type].to_sym 138 when :radio, :checkbox 139 tag.attr[:checked] ? '_X_' : '___' 140 when :submit, :reset, :hidden 141 '' 142 when :password 143 "********\n" 144 else 145 "#{tag.attr[:value].to_s}\n" 146 end 147 when :select 148 "\n#{call(tag.children)}" 149 when :option 150 "#{call([tag.attr[:selected] ? '_X_ ' : '___ ', tag.children])}\n" 151 when :textarea, :label 152 "#{call(tag.children)}\n" 153 when :legend 154 v = call(tag.children) 155 "#{v}\n#{'-' * v.length}\n" 156 else 157 call(tag.children) 158 end 159 when Input 160 call(tag.format) 161 when Array 162 tag.map{|x| call(x)}.join 163 else 164 tag.to_s 165 end 166 end