require "nokogiri"
require "we_bridge/html_builder/version"
require "we_bridge/html_builder/handler"
module WeBridge
module HtmlBuilder
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
def self.register_template_handler(extension = nil)
handler = WeBridge::HtmlBuilder::Handler
ActionView::Template.register_template_handler(extension || handler.default_extension, handler) if defined? ActionView::Template
ActionView::Helpers.__send__(:include,self) if defined? ActionView::Helpers
end
end
end
require "we_bridge/html_builder/railtie" if defined? Rails