9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/haml2erb/erb_writer.rb', line 9
def <<(line_options)
close_tags(line_options[:indent])
@tag_stack.push(line_options[:element_type]) if line_options[:element_type]
@processed << (" " * line_options[:indent]) if line_options[:indent]
@processed << "<#{line_options[:element_type].to_s}" if line_options[:element_type]
@processed << " id='#{line_options[:element_id].to_s}'" if line_options[:element_id]
@processed << " class='#{[*line_options[:element_class]].join(' ')}'" if line_options[:element_class]
line_options[:element_attributes] && line_options[:element_attributes].keys.each do |attribute_key|
@processed << " #{attribute_key}='#{line_options[:element_attributes][attribute_key]}'"
end
@processed << ">" if line_options[:element_type]
case(line_options[:content_type])
when :text
@processed << (line_options[:contents] || "")
when :ruby
@processed << ("<%= " + line_options[:contents] + " %>")
when :mixed
@processed << ('<%= "' + line_options[:contents] + '" %>')
end
close_tags(line_options[:indent], :separate_line => false) if line_options[:contents]
@processed << "\n"
end
|