Sha256: 7b3baf94b5bec0e8d1d18228de549a2caef1a044d87e19c86966f09d0d1e2275

Contents?: true

Size: 576 Bytes

Versions: 3

Compression:

Stored size: 576 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

3 entries across 3 versions & 2 rubygems

Version Path
bootstrap_form-4.0.0 demo/app/helpers/bootstrap_helper.rb
bootstrap_form-4.0.0.alpha1 demo/app/helpers/bootstrap_helper.rb
bootstrap_form_legacy-4.0.1.dev demo/app/helpers/bootstrap_helper.rb