Class: RbbCode::HtmlMaker

Inherits:
Object
  • Object
show all
Defined in:
lib/rbbcode/html_maker.rb

Instance Method Summary collapse

Instance Method Details

#make_html(node) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rbbcode/html_maker.rb', line 19

def make_html(node)
	output = ''
	case node.class.to_s
	when 'RbbCode::RootNode'
		node.children.each do |child|
			output << make_html(child)
		end
	when 'RbbCode::TagNode'
		custom_tag_method = "html_from_#{node.tag_name}_tag"
		if respond_to?(custom_tag_method)
			output << send(custom_tag_method, node)
		else
			inner_html = ''
			node.children.each do |child|
				inner_html << make_html(child)
			end
			output << (map_tag_name(node.tag_name), inner_html)
		end
	when 'RbbCode::TextNode'
		output << node.text
	else
		raise "Don't know how to make HTML from #{node.class}"
	end
	output
end