Sha256: 48a33ee95d8386d9529a7842b13d1c183b2e94236f1a62f716392375ad6c571e

Contents?: true

Size: 1.57 KB

Versions: 52

Compression:

Stored size: 1.57 KB

Contents

require 'helper'

class TestSlimTextInterpolation < TestSlim
  def test_interpolation_in_attribute
    source = %q{
p id="a#{id_helper}b" = hello_world
}

    assert_html '<p id="anoticeb">Hello World from @env</p>', source
  end

  def test_nested_interpolation_in_attribute
    source = %q{
p id="#{"abc#{1+1}" + "("}" = hello_world
}

    assert_html '<p id="abc2(">Hello World from @env</p>', source
  end

  def test_interpolation_in_text
    source = %q{
p
 | #{hello_world} with "quotes"
p
 |
  A message from the compiler: #{hello_world}
}

    assert_html '<p>Hello World from @env with "quotes"</p><p>A message from the compiler: Hello World from @env</p>', source
  end

  def test_interpolation_in_tag
    source = %q{
p #{hello_world}
}

    assert_html '<p>Hello World from @env</p>', source
  end

  def test_escape_interpolation
    source = %q{
p \\#{hello_world}
}

    assert_html '<p>#{hello_world}</p>', source
  end

  def test_complex_interpolation
    source = %q{
p Message: #{message('hello', "user #{output_number}")}
}

    assert_html '<p>Message: hello user 1337</p>', source
  end

  def test_interpolation_with_escaping
    source = %q{
| #{evil_method}
}

    assert_html '&lt;script&gt;do_something_evil();&lt;&#47;script&gt;', source
  end

  def test_interpolation_without_escaping
    source = %q{
| #{{evil_method}}
}

    assert_html '<script>do_something_evil();</script>', source
  end

  def test_interpolation_with_escaping_and_delimiter
    source = %q{
| #{(evil_method)}
}
    assert_html '&lt;script&gt;do_something_evil();&lt;&#47;script&gt;', source
  end
end

Version data entries

52 entries across 52 versions & 2 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.7.4 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.7.3 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.7.2 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.7.1 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.7.0 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.9 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.8 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.7 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.6 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.5 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.4 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.3 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.2 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.1 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.6.0 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.5.17 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.5.16 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.5.15 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb
classiccms-0.5.14 vendor/bundle/gems/slim-1.2.0/test/slim/test_text_interpolation.rb