Sha256: 93e89d5793142b5281c31dee407c44e15f4920a481a6287b7b07e44d8688b52a

Contents?: true

Size: 574 Bytes

Versions: 1

Compression:

Stored size: 574 Bytes

Contents

module BootstrapHelper
  def form_with_source(&block)
    form_html = capture(&block)

    content_tag(:div, class: "example") do
      codemirror = content_tag(:div, class: "code", style: "display: none") do
        content_tag(:textarea, class: "codemirror") do
          HtmlBeautifier.beautify(form_html.strip.gsub(">", ">\n").gsub("<", "\n<"))
        end
      end

      toggle = content_tag(:button, class: "toggle btn btn-sm btn-info") do
        "Show Source Code"
      end

      concat(form_html)
      concat(toggle)
      concat(codemirror)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bootstrap_form-4.1.0 demo/app/helpers/bootstrap_helper.rb