tilt 0.3 → 0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tilt
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.3"
4
+ version: "0.4"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Tomayko
@@ -9,10 +9,79 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-16 00:00:00 -07:00
12
+ date: 2009-12-13 00:00:00 -08:00
13
13
  default_executable:
14
- dependencies: []
15
-
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: contest
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: builder
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: erubis
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: "0"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: haml
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: mustache
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: rdiscount
67
+ type: :development
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: liquid
77
+ type: :development
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: "0"
84
+ version:
16
85
  description: Generic interface to multiple Ruby template engines
17
86
  email: r@tomayko.com
18
87
  executables: []
@@ -28,18 +97,20 @@ files:
28
97
  - TEMPLATES.md
29
98
  - bin/tilt
30
99
  - lib/tilt.rb
31
- - test/.bacon
32
- - test/spec_tilt.rb
33
- - test/spec_tilt_buildertemplate.rb
34
- - test/spec_tilt_erbtemplate.rb
35
- - test/spec_tilt_erubistemplate.rb
36
- - test/spec_tilt_hamltemplate.rb
37
- - test/spec_tilt_liquid_template.rb
38
- - test/spec_tilt_mustachetemplate.rb
39
- - test/spec_tilt_rdiscount.rb
40
- - test/spec_tilt_sasstemplate.rb
41
- - test/spec_tilt_stringtemplate.rb
42
- - test/spec_tilt_template.rb
100
+ - test/tilt_buildertemplate_test.rb
101
+ - test/tilt_cache_test.rb
102
+ - test/tilt_erbtemplate_test.rb
103
+ - test/tilt_erubistemplate_test.rb
104
+ - test/tilt_hamltemplate_test.rb
105
+ - test/tilt_liquidtemplate_test.rb
106
+ - test/tilt_mustachetemplate_test.rb
107
+ - test/tilt_rdiscounttemplate_test.rb
108
+ - test/tilt_rdoctemplate_test.rb
109
+ - test/tilt_redclothtemplate_test.rb
110
+ - test/tilt_sasstemplate_test.rb
111
+ - test/tilt_stringtemplate_test.rb
112
+ - test/tilt_template_test.rb
113
+ - test/tilt_test.rb
43
114
  - tilt.gemspec
44
115
  has_rdoc: true
45
116
  homepage: http://github.com/rtomayko/tilt/
@@ -70,19 +141,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
141
  requirements: []
71
142
 
72
143
  rubyforge_project: wink
73
- rubygems_version: 1.3.4
144
+ rubygems_version: 1.3.5
74
145
  signing_key:
75
146
  specification_version: 2
76
147
  summary: Generic interface to multiple Ruby template engines
77
- test_files:
78
- - test/spec_tilt.rb
79
- - test/spec_tilt_buildertemplate.rb
80
- - test/spec_tilt_erbtemplate.rb
81
- - test/spec_tilt_erubistemplate.rb
82
- - test/spec_tilt_hamltemplate.rb
83
- - test/spec_tilt_liquid_template.rb
84
- - test/spec_tilt_mustachetemplate.rb
85
- - test/spec_tilt_rdiscount.rb
86
- - test/spec_tilt_sasstemplate.rb
87
- - test/spec_tilt_stringtemplate.rb
88
- - test/spec_tilt_template.rb
148
+ test_files: []
149
+
File without changes
@@ -1,53 +0,0 @@
1
- require 'bacon'
2
- require 'tilt'
3
-
4
- describe Tilt do
5
- class MockTemplate
6
- attr_reader :args, :block
7
- def initialize(*args, &block)
8
- @args = args
9
- @block = block
10
- end
11
- end
12
-
13
- it "registers template implementation classes by file extension" do
14
- lambda { Tilt.register('mock', MockTemplate) }.should.not.raise
15
- end
16
-
17
- it "registers template implementation classes by a file extension given as a symbol" do
18
- lambda { Tilt.register(:mock, MockTemplate) }.should.not.raise
19
- end
20
-
21
- it "looks up template implementation classes by file extension" do
22
- impl = Tilt['mock']
23
- impl.should.equal MockTemplate
24
-
25
- impl = Tilt['.mock']
26
- impl.should.equal MockTemplate
27
- end
28
-
29
- it "looks up template implementation classes with multiple file extensions" do
30
- impl = Tilt['index.html.mock']
31
- impl.should.equal MockTemplate
32
- end
33
-
34
- it "looks up template implementation classes by file name" do
35
- impl = Tilt['templates/test.mock']
36
- impl.should.equal MockTemplate
37
- end
38
-
39
- it "gives nil when no template implementation classes exist for a filename" do
40
- Tilt['none'].should.be.nil
41
- end
42
-
43
- it "exposes the file pattern -> template class Hash at Tilt::mappings" do
44
- Tilt.should.respond_to :mappings
45
- Tilt.mappings.should.respond_to :[]
46
- end
47
-
48
- it "creates a new template instance given a filename" do
49
- template = Tilt.new('foo.mock', 1, :key => 'val') { 'Hello World!' }
50
- template.args.should.equal ['foo.mock', 1, {:key => 'val'}]
51
- template.block.call.should.equal 'Hello World!'
52
- end
53
- end
@@ -1,41 +0,0 @@
1
- require 'bacon'
2
- require 'tilt'
3
- require 'erb'
4
- require 'builder'
5
-
6
- describe Tilt::BuilderTemplate do
7
- it "is registered for '.builder' files" do
8
- Tilt['test.builder'].should.equal Tilt::BuilderTemplate
9
- Tilt['test.xml.builder'].should.equal Tilt::BuilderTemplate
10
- end
11
-
12
- it "compiles and evaluates the template on #render" do
13
- template = Tilt::BuilderTemplate.new { |t| "xml.em 'Hello World!'" }
14
- template.render.should.equal "<em>Hello World!</em>\n"
15
- end
16
-
17
- it "supports locals" do
18
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + name + '!')" }
19
- template.render(Object.new, :name => 'Joe').should.equal "<em>Hey Joe!</em>\n"
20
- end
21
-
22
- it "is evaluated in the object scope provided" do
23
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + @name + '!')" }
24
- scope = Object.new
25
- scope.instance_variable_set :@name, 'Joe'
26
- template.render(scope).should.equal "<em>Hey Joe!</em>\n"
27
- end
28
-
29
- it "evaluates template_source with yield support" do
30
- template = Tilt::BuilderTemplate.new { "xml.em('Hey ' + yield + '!')" }
31
- template.render { 'Joe' }.should.equal "<em>Hey Joe!</em>\n"
32
- end
33
-
34
- it "calls a block directly when" do
35
- template =
36
- Tilt::BuilderTemplate.new do |t|
37
- lambda { |xml| xml.em('Hey Joe!') }
38
- end
39
- template.render.should.equal "<em>Hey Joe!</em>\n"
40
- end
41
- end
@@ -1,93 +0,0 @@
1
- require 'bacon'
2
- require 'tilt'
3
- require 'erb'
4
-
5
- describe Tilt::ERBTemplate do
6
- it "is registered for '.erb' files" do
7
- Tilt['test.erb'].should.equal Tilt::ERBTemplate
8
- Tilt['test.html.erb'].should.equal Tilt::ERBTemplate
9
- end
10
-
11
- it "is registered for '.rhtml' files" do
12
- Tilt['test.rhtml'].should.equal Tilt::ERBTemplate
13
- end
14
-
15
- it "compiles and evaluates the template on #render" do
16
- template = Tilt::ERBTemplate.new { |t| "Hello World!" }
17
- template.render.should.equal "Hello World!"
18
- end
19
-
20
- it "supports locals" do
21
- template = Tilt::ERBTemplate.new { 'Hey <%= name %>!' }
22
- template.render(Object.new, :name => 'Joe').should.equal "Hey Joe!"
23
- end
24
-
25
- it "is evaluated in the object scope provided" do
26
- template = Tilt::ERBTemplate.new { 'Hey <%= @name %>!' }
27
- scope = Object.new
28
- scope.instance_variable_set :@name, 'Joe'
29
- template.render(scope).should.equal "Hey Joe!"
30
- end
31
-
32
- it "evaluates template_source with yield support" do
33
- template = Tilt::ERBTemplate.new { 'Hey <%= yield %>!' }
34
- template.render { 'Joe' }.should.equal "Hey Joe!"
35
- end
36
-
37
- it "reports the file and line properly in backtraces without locals" do
38
- data = File.read(__FILE__).split("\n__END__\n").last
39
- fail unless data[0] == ?<
40
- template = Tilt::ERBTemplate.new('test.erb', 11) { data }
41
- begin
42
- template.render
43
- flunk 'should have raised an exception'
44
- rescue => boom
45
- boom.should.be.kind_of NameError
46
- line = boom.backtrace.first
47
- file, line, meth = line.split(":")
48
- file.should.equal 'test.erb'
49
- line.should.equal '13'
50
- end
51
- end
52
-
53
- it "reports the file and line properly in backtraces with locals" do
54
- data = File.read(__FILE__).split("\n__END__\n").last
55
- fail unless data[0] == ?<
56
- template = Tilt::ERBTemplate.new('test.erb', 1) { data }
57
- begin
58
- template.render(nil, :name => 'Joe', :foo => 'bar')
59
- flunk 'should have raised an exception'
60
- rescue => boom
61
- boom.should.be.kind_of RuntimeError
62
- line = boom.backtrace.first
63
- file, line, meth = line.split(":")
64
- file.should.equal 'test.erb'
65
- line.should.equal '6'
66
- end
67
- end
68
-
69
- it "renders erb templates with new lines by default" do
70
- template = Tilt.new('test.erb', 1) { "\n<%= 1 + 1 %>\n" }
71
- template.render.should.equal "\n2\n"
72
- end
73
-
74
- it "strips new lines explicitly when :trim option is set to '-'" do
75
- template = Tilt.new('test.erb', 1, :trim => '-') { "\n<%= 1 + 1 -%>\n" }
76
- template.render.should.equal "\n2"
77
- end
78
-
79
- it "processes lines start with % when :trim option is set to '%'" do
80
- template = Tilt.new('test.erb', 1, :trim => '%') { "\n% if true\nhello\n%end\n" }
81
- template.render.should.equal "\nhello\n"
82
- end
83
- end
84
-
85
- __END__
86
- <html>
87
- <body>
88
- <h1>Hey <%= name %>!</h1>
89
-
90
-
91
- <p><% fail %></p>
92
- </body>
93
- </html>
@@ -1,78 +0,0 @@
1
- require 'bacon'
2
- require 'tilt'
3
-
4
- begin
5
- require 'erubis'
6
- describe "Tilt::ErubisTemplate" do
7
- it "is registered for '.erubis' files" do
8
- Tilt['test.erubis'].should.equal Tilt::ErubisTemplate
9
- Tilt['test.html.erubis'].should.equal Tilt::ErubisTemplate
10
- end
11
-
12
- it "compiles and evaluates the template on #render" do
13
- template = Tilt::ErubisTemplate.new { |t| "Hello World!" }
14
- template.render.should.equal "Hello World!"
15
- end
16
-
17
- it "supports locals" do
18
- template = Tilt::ErubisTemplate.new { 'Hey <%= name %>!' }
19
- template.render(Object.new, :name => 'Joe').should.equal "Hey Joe!"
20
- end
21
-
22
- it "is evaluated in the object scope provided" do
23
- template = Tilt::ErubisTemplate.new { 'Hey <%= @name %>!' }
24
- scope = Object.new
25
- scope.instance_variable_set :@name, 'Joe'
26
- template.render(scope).should.equal "Hey Joe!"
27
- end
28
-
29
- it "evaluates template_source with yield support" do
30
- template = Tilt::ErubisTemplate.new { 'Hey <%= yield %>!' }
31
- template.render { 'Joe' }.should.equal "Hey Joe!"
32
- end
33
-
34
- it "reports the file and line properly in backtraces without locals" do
35
- data = File.read(__FILE__).split("\n__END__\n").last
36
- fail unless data[0] == ?<
37
- template = Tilt::ErubisTemplate.new('test.erubis', 11) { data }
38
- begin
39
- template.render
40
- flunk 'should have raised an exception'
41
- rescue => boom
42
- boom.should.be.kind_of NameError
43
- line = boom.backtrace.first
44
- file, line, meth = line.split(":")
45
- file.should.equal 'test.erubis'
46
- line.should.equal '13'
47
- end
48
- end
49
-
50
- it "reports the file and line properly in backtraces with locals" do
51
- data = File.read(__FILE__).split("\n__END__\n").last
52
- fail unless data[0] == ?<
53
- template = Tilt::ErubisTemplate.new('test.erubis', 1) { data }
54
- begin
55
- template.render(nil, :name => 'Joe', :foo => 'bar')
56
- flunk 'should have raised an exception'
57
- rescue => boom
58
- boom.should.be.kind_of RuntimeError
59
- line = boom.backtrace.first
60
- file, line, meth = line.split(":")
61
- file.should.equal 'test.erubis'
62
- line.should.equal '6'
63
- end
64
- end
65
- end
66
- rescue LoadError => boom
67
- warn "Tilt::ErubisTemplate (disabled)\n"
68
- end
69
-
70
- __END__
71
- <html>
72
- <body>
73
- <h1>Hey <%= name %>!</h1>
74
-
75
-
76
- <p><% fail %></p>
77
- </body>
78
- </html>
@@ -1,25 +0,0 @@
1
- require 'bacon'
2
- require 'tilt'
3
-
4
- begin
5
- require 'liquid'
6
-
7
- describe Tilt::LiquidTemplate do
8
- it "is registered for '.liquid' files" do
9
- Tilt['test.liquid'].should.equal Tilt::LiquidTemplate
10
- end
11
-
12
- it "compiles and evaluates the template on #render" do
13
- template = Tilt::LiquidTemplate.new { |t| "Hello World!" }
14
- template.render.should.equal "Hello World!"
15
- end
16
-
17
- it "supports locals" do
18
- template = Tilt::LiquidTemplate.new { "Hey {{ name }}!" }
19
- template.render(nil, :name => 'Joe').should.equal "Hey Joe!"
20
- end
21
- end
22
-
23
- rescue LoadError => boom
24
- warn "Tilt::LiquidTemplate (disabled)\n"
25
- end
@@ -1,19 +0,0 @@
1
- require 'bacon'
2
- require 'tilt'
3
-
4
- begin
5
- require 'rdiscount'
6
-
7
- describe Tilt::RDiscountTemplate do
8
- it "is registered for '.markdown' files" do
9
- Tilt['test.markdown'].should.equal Tilt::RDiscountTemplate
10
- end
11
-
12
- it "compiles and evaluates the template on #render" do
13
- template = Tilt::RDiscountTemplate.new { |t| "# Hello World!" }
14
- template.render.should.equal "<h1>Hello World!</h1>\n"
15
- end
16
- end
17
- rescue LoadError => boom
18
- warn "Tilt::RDiscountTemplate (disabled)\n"
19
- end