Sha256: dc75d3c4f5a7c8439a9dc324ab88b465150ae3474318e11857c009acf2900051

Contents?: true

Size: 1.1 KB

Versions: 53

Compression:

Stored size: 1.1 KB

Contents

require 'helper'
require 'erb'
require 'tilt'

describe Temple::ERB::Engine do
  it 'should compile erb' do
    src = %q{
%% hi
= hello
<% 3.times do |n| %>
* <%= n %>
<% end %>
}

    erb(src).should.equal ERB.new(src).result
  end

  it 'should recognize comments' do
    src = %q{
hello
  <%# comment -- ignored -- useful in testing %>
world}

    erb(src).should.equal ERB.new(src).result
  end

  it 'should recognize <%% and %%>' do
    src = %q{
<%%
<% if true %>
  %%>
<% end %>
}

    erb(src).should.equal "\n<%\n\n  %>\n\n" #ERB.new(src).result
  end

  it 'should escape automatically' do
    src = '<%= "<" %>'
    ans = '&lt;'
    erb(src, :auto_escape => true).should.equal ans
  end

  it 'should support == to disable automatic escape' do
    src = '<%== "<" %>'
    ans = '<'
    erb(src, :auto_escape => true).should.equal ans
  end

  it 'should support trim mode' do
    src = %q{
%% hi
= hello
<% 3.times do |n| %>
* <%= n %>
<% end %>
}

    erb(src, :trim_mode => '>').should.equal ERB.new(src, nil, '>').result
    erb(src, :trim_mode => '<>').should.equal ERB.new(src, nil, '<>').result
  end
end

Version data entries

53 entries across 53 versions & 2 rubygems

Version Path
classiccms-0.3.5 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.3.4 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.3.3 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.3.2 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.3.1 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.3.0 vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
classiccms-0.2.4.pre vendor/bundle/gems/temple-0.4.0/test/test_erb.rb
temple-0.4.0 test/test_erb.rb
temple-0.3.5 test/test_erb.rb
temple-0.3.4 test/test_erb.rb
temple-0.3.2 test/test_erb.rb
temple-0.3.1 test/test_erb.rb
temple-0.3.0 test/test_erb.rb