Sha256: 47f6aeb60cc2ab13cb8156ea88039b3a95423cfeb40afae4a2d636946de60ef8

Contents?: true

Size: 611 Bytes

Versions: 4

Compression:

Stored size: 611 Bytes

Contents

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

    content_tag(:div, class: "example") do
      concat(form_html)
      concat(toggle)
      concat(codemirror(form_html))
    end
  end

  private

  def codemirror(form_html)
    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
  end

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

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/bootstrap_form-4.5.0/demo/app/helpers/bootstrap_helper.rb
bootstrap_form-4.5.0 demo/app/helpers/bootstrap_helper.rb
bootstrap_form-4.4.0 demo/app/helpers/bootstrap_helper.rb
bootstrap_form-4.3.0 demo/app/helpers/bootstrap_helper.rb