Sha256: f8340ffb3a83356726ad735b17eb67598200697567b93caf3321136278dcb10c

Contents?: true

Size: 1.98 KB

Versions: 44

Compression:

Stored size: 1.98 KB

Contents

require 'helper'

describe Temple::HTML::Pretty do
  before do
    @html = Temple::HTML::Pretty.new
  end

  it 'should indent nested tags' do
    @html.call([:html, :tag, 'div', [:multi],
      [:html, :tag, 'p', [:multi], [:multi, [:static, 'text'], [:dynamic, 'code']]]
    ]).should.equal [:multi,
                     [:code, "_temple_html_pretty1 = /<code|<pre|<textarea/"],
                     [:multi,
                      [:static, "<div"],
                      [:multi],
                      [:static, ">"],
                      [:multi,
                       [:static, "\n  <p"],
                       [:multi],
                       [:static, ">"],
                       [:multi,
                        [:static, "\n    text"],
                        [:dynamic, "::Temple::Utils.indent_dynamic((code), false, \"\\n    \", _temple_html_pretty1)"]],
                       [:static, "\n  </p>"]],
                      [:static, "\n</div>"]]]
  end

  it 'should not indent preformatted tags' do
    @html.call([:html, :tag, 'pre', [:multi],
      [:html, :tag, 'p', [:multi], [:static, 'text']]
    ]).should.equal [:multi,
                     [:code, "_temple_html_pretty1 = /<code|<pre|<textarea/"],
                     [:multi,
                      [:static, "<pre"],
                      [:multi],
                      [:static, ">"],
                      [:multi,
                       [:static, "<p"],
                       [:multi],
                       [:static, ">"],
                       [:static, "text"],
                       [:static, "</p>"]],
                      [:static, "</pre>"]]]
  end

  it 'should not escape html_safe strings' do
    with_html_safe do
      @html.call(
        [:dynamic, '"text<".html_safe']
      ).should.equal [:multi,
                      [:code, "_temple_html_pretty1 = /<code|<pre|<textarea/"],
                      [:dynamic, "::Temple::Utils.indent_dynamic((\"text<\".html_safe), nil, \"\\n\", _temple_html_pretty1)"]]
    end
  end
end

Version data entries

44 entries across 44 versions & 6 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/test/html/test_pretty.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/test/html/test_pretty.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/temple-0.8.2/test/html/test_pretty.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/temple-0.8.2/test/html/test_pretty.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/temple-0.8.2/test/html/test_pretty.rb
temple-0.9.0 test/html/test_pretty.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/temple-0.8.0/test/html/test_pretty.rb
temple-0.8.2 test/html/test_pretty.rb
temple-0.8.1 test/html/test_pretty.rb
brakeman-4.3.1 bundle/ruby/2.5.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-4.3.0 bundle/ruby/2.5.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-4.2.1 bundle/ruby/2.5.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-4.2.0 bundle/ruby/2.3.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-4.1.1 bundle/ruby/2.3.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-4.1.0 bundle/ruby/2.3.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-4.0.1 bundle/ruby/2.3.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-4.0.1.pre1 bundle/ruby/2.3.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-4.0.0 bundle/ruby/2.3.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-3.7.2 bundle/ruby/2.3.0/gems/temple-0.7.7/test/html/test_pretty.rb
brakeman-3.7.1 bundle/ruby/2.3.0/gems/temple-0.7.7/test/html/test_pretty.rb