Module: WeBridge::HtmlBuilder
- Defined in:
- lib/we_bridge/html_builder.rb,
lib/we_bridge/html_builder/handler.rb,
lib/we_bridge/html_builder/railtie.rb,
lib/we_bridge/html_builder/version.rb
Defined Under Namespace
Classes: Handler, Railtie
Constant Summary
collapse
- VERSION =
"0.1.7"
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.register_template_handler(extension = nil) ⇒ Object
20
21
22
23
24
|
# File 'lib/we_bridge/html_builder.rb', line 20
def self.register_template_handler(extension = nil)
handler = WeBridge::HtmlBuilder::Handler
ActionView::Template.register_template_handler(extension || handler.default_extension, handler)
ActionView::Base.__send__(:include,self)
end
|
Instance Method Details
#markup(tag_name = nil, option = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/we_bridge/html_builder.rb', line 6
def markup(tag_name=nil, option={})
root = Nokogiri::HTML::DocumentFragment.parse('')
Nokogiri::HTML::Builder.with(root) do |doc|
if tag_name
doc.send(tag_name, options) do
yield doc
end
else
yield doc
end
end
root.to_html
end
|