Sha256: ffd7355ac098aa0b87c83dc6870ab991910f4bbf98c6eceb7453d4719a8ae029

Contents?: true

Size: 1.79 KB

Versions: 1

Compression:

Stored size: 1.79 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, "text"],
                        [:multi,
                         [:code, "_temple_html_pretty2 = (code).to_s"],
                         [:code, '_temple_html_pretty2 = _temple_html_pretty2.gsub("\n", "\n    ") if _temple_html_pretty1 !~ _temple_html_pretty2'],
                         [:dynamic, "_temple_html_pretty2"]]],
                       [:static, "</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
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
temple-0.3.1 test/html/test_pretty.rb