deprecate #erubis
This commit is contained in:
parent
9b94ee6550
commit
3e641dbf66
24
README.rdoc
24
README.rdoc
|
@ -256,30 +256,6 @@ and overridden on an individual basis.
|
|||
|
||||
Renders <tt>./views/index.erb</tt>.
|
||||
|
||||
=== Erubis Templates
|
||||
|
||||
The <tt>erubis</tt> gem/library is required to render Erubis templates:
|
||||
|
||||
# You'll need to require erubis in your app
|
||||
require 'erubis'
|
||||
|
||||
get '/' do
|
||||
erubis :index
|
||||
end
|
||||
|
||||
Renders <tt>./views/index.erubis</tt>.
|
||||
|
||||
It is also possible to replace Erb with Erubis:
|
||||
|
||||
require 'erubis'
|
||||
Tilt.register :erb, Tilt[:erubis]
|
||||
|
||||
get '/' do
|
||||
erb :index
|
||||
end
|
||||
|
||||
Renders <tt>./views/index.erb</tt> with Erubis.
|
||||
|
||||
=== Builder Templates
|
||||
|
||||
The <tt>builder</tt> gem/library is required to render builder templates:
|
||||
|
|
|
@ -451,6 +451,8 @@ module Sinatra
|
|||
end
|
||||
|
||||
def erubis(template, options={}, locals={})
|
||||
warn "Sinatra::Templates#erubis is deprecated and will be removed, use #erb insetad.\n" \
|
||||
"If you have Erubis installed, it will be used automatically.\n\tfrom #{caller.first}"
|
||||
render :erubis, template, options, locals
|
||||
end
|
||||
|
||||
|
|
|
@ -44,7 +44,6 @@ Gem::Specification.new do |s|
|
|||
test/delegator_test.rb
|
||||
test/encoding_test.rb
|
||||
test/erb_test.rb
|
||||
test/erubis_test.rb
|
||||
test/extensions_test.rb
|
||||
test/filter_test.rb
|
||||
test/haml_test.rb
|
||||
|
@ -80,7 +79,6 @@ Gem::Specification.new do |s|
|
|||
test/views/calc.html.erb
|
||||
test/views/error.builder
|
||||
test/views/error.erb
|
||||
test/views/error.erubis
|
||||
test/views/error.haml
|
||||
test/views/error.sass
|
||||
test/views/explicitly_nested.str
|
||||
|
@ -88,7 +86,6 @@ Gem::Specification.new do |s|
|
|||
test/views/hello.builder
|
||||
test/views/hello.coffee
|
||||
test/views/hello.erb
|
||||
test/views/hello.erubis
|
||||
test/views/hello.haml
|
||||
test/views/hello.less
|
||||
test/views/hello.liquid
|
||||
|
@ -105,7 +102,6 @@ Gem::Specification.new do |s|
|
|||
test/views/hello.textile
|
||||
test/views/layout2.builder
|
||||
test/views/layout2.erb
|
||||
test/views/layout2.erubis
|
||||
test/views/layout2.haml
|
||||
test/views/layout2.liquid
|
||||
test/views/layout2.mab
|
||||
|
|
|
@ -1,88 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/helper'
|
||||
|
||||
begin
|
||||
require 'erubis'
|
||||
|
||||
class ERubisTest < Test::Unit::TestCase
|
||||
def erubis_app(&block)
|
||||
mock_app {
|
||||
set :views, File.dirname(__FILE__) + '/views'
|
||||
get '/', &block
|
||||
}
|
||||
get '/'
|
||||
end
|
||||
|
||||
it 'renders inline ERubis strings' do
|
||||
erubis_app { erubis '<%= 1 + 1 %>' }
|
||||
assert ok?
|
||||
assert_equal '2', body
|
||||
end
|
||||
|
||||
it 'renders .erubis files in views path' do
|
||||
erubis_app { erubis :hello }
|
||||
assert ok?
|
||||
assert_equal "Hello World\n", body
|
||||
end
|
||||
|
||||
it 'takes a :locals option' do
|
||||
erubis_app {
|
||||
locals = {:foo => 'Bar'}
|
||||
erubis '<%= foo %>', :locals => locals
|
||||
}
|
||||
assert ok?
|
||||
assert_equal 'Bar', body
|
||||
end
|
||||
|
||||
it "renders with inline layouts" do
|
||||
mock_app {
|
||||
layout { 'THIS. IS. <%= yield.upcase %>!' }
|
||||
get('/') { erubis 'Sparta' }
|
||||
}
|
||||
get '/'
|
||||
assert ok?
|
||||
assert_equal 'THIS. IS. SPARTA!', body
|
||||
end
|
||||
|
||||
it "renders with file layouts" do
|
||||
erubis_app {
|
||||
erubis 'Hello World', :layout => :layout2
|
||||
}
|
||||
assert ok?
|
||||
assert_equal "ERubis Layout!\nHello World\n", body
|
||||
end
|
||||
|
||||
it "renders erubis with blocks" do
|
||||
mock_app {
|
||||
def container
|
||||
@_out_buf << "THIS."
|
||||
yield
|
||||
@_out_buf << "SPARTA!"
|
||||
end
|
||||
def is; "IS." end
|
||||
get '/' do
|
||||
erubis '<% container do %> <%= is %> <% end %>'
|
||||
end
|
||||
}
|
||||
get '/'
|
||||
assert ok?
|
||||
assert_equal 'THIS. IS. SPARTA!', body
|
||||
end
|
||||
|
||||
it "can be used in a nested fashion for partials and whatnot" do
|
||||
mock_app {
|
||||
template(:inner) { "<inner><%= 'hi' %></inner>" }
|
||||
template(:outer) { "<outer><%= erubis :inner %></outer>" }
|
||||
get '/' do
|
||||
erubis :outer
|
||||
end
|
||||
}
|
||||
|
||||
get '/'
|
||||
assert ok?
|
||||
assert_equal '<outer><inner>hi</inner></outer>', body
|
||||
end
|
||||
end
|
||||
|
||||
rescue LoadError
|
||||
warn "#{$!.to_s}: skipping erubis tests"
|
||||
end
|
|
@ -1,3 +0,0 @@
|
|||
Hello <%= 'World' %>
|
||||
<% raise 'Goodbye' unless defined?(french) && french %>
|
||||
<% raise 'Au revoir' if defined?(french) && french %>
|
|
@ -1 +0,0 @@
|
|||
Hello <%= 'World' %>
|
|
@ -1,2 +0,0 @@
|
|||
ERubis Layout!
|
||||
<%= yield %>
|
Loading…
Reference in New Issue