Sha256: f1a8cdb92ab894044268baa90984299810abedcf77fe7ede68abfca442a42335

Contents?: true

Size: 803 Bytes

Versions: 2

Compression:

Stored size: 803 Bytes

Contents

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)
      ActionView::Base.__send__(:include,self)
    end
  end
end

require "we_bridge/html_builder/railtie" if defined? Rails::Railtie

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
we_bridge-html_builder-0.1.7 lib/we_bridge/html_builder.rb
we_bridge-html_builder-0.1.6 lib/we_bridge/html_builder.rb