tilt 2.0.0.beta1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile +4 -4
- data/README.md +2 -1
- data/docs/TEMPLATES.md +1 -0
- data/lib/tilt.rb +4 -2
- data/lib/tilt/mapping.rb +20 -2
- data/lib/tilt/template.rb +3 -1
- data/test/test_helper.rb +2 -0
- data/test/{tilt_mapping.rb → tilt_mapping_test.rb} +14 -0
- data/test/tilt_markdown_test.rb +10 -7
- data/test/tilt_marukutemplate_test.rb +3 -3
- data/test/tilt_rdiscounttemplate_test.rb +1 -1
- data/test/tilt_template_test.rb +7 -0
- data/tilt.gemspec +3 -3
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f43cb3f1357b1eeb55d129fed314692c5c053322
|
4
|
+
data.tar.gz: 63ba1cd6367f652f75c968a479530ae6830dc663
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a30fa65c04fe76bb58af64df4d1940272507d765b942eea1433ad070f0f924566f0c5b3569700dd50f947fc9c6bafe634a46c77279c42e4ac22ee8133e7adcf
|
7
|
+
data.tar.gz: eca0811f6a72525467c766996191feb3c0bc59b533dbe91831379e7ba3142b4010f37452b232d52145431e66391c3c0a858c0457a8dbe98bd857e1cbc7e0a015
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## master
|
2
2
|
|
3
|
+
* Add Handlebars as external template engine (#204, judofyr, jimothyGator)
|
4
|
+
* Add org-ruby as external template engine (#207, judofyr, minad)
|
5
|
+
* Documentation typo (#208, elgalu)
|
6
|
+
|
7
|
+
## 2.0.0.beta1 (2013-07-16)
|
8
|
+
|
9
|
+
* Documentation typo (#202, chip)
|
10
|
+
* Use YARD for documentation (#189, judofyr)
|
11
|
+
* Add Slim as an external template engine (judofyr)
|
3
12
|
* Add Tilt.templates_for (#121, judofyr)
|
4
13
|
* Add Tilt.current_template (#151, judofyr)
|
5
14
|
* Avoid loading all files in tilt.rb (#160, #187, judofyr)
|
data/Gemfile
CHANGED
@@ -18,7 +18,7 @@ group :engines do
|
|
18
18
|
gem 'liquid'
|
19
19
|
gem 'markaby'
|
20
20
|
gem 'maruku'
|
21
|
-
gem 'nokogiri'
|
21
|
+
gem 'nokogiri' if RUBY_VERSION > '1.9.2'
|
22
22
|
gem 'radius'
|
23
23
|
gem 'sass'
|
24
24
|
gem 'wikicloth'
|
@@ -26,14 +26,14 @@ group :engines do
|
|
26
26
|
|
27
27
|
platform :ruby do
|
28
28
|
gem 'yajl-ruby'
|
29
|
-
gem 'redcarpet'
|
30
|
-
gem 'rdiscount' if RUBY_VERSION != '1.9.2'
|
29
|
+
gem 'redcarpet' if RUBY_VERSION > '1.8.7'
|
30
|
+
gem 'rdiscount', '>= 2.1.6' if RUBY_VERSION != '1.9.2'
|
31
31
|
gem 'RedCloth'
|
32
32
|
end
|
33
33
|
|
34
34
|
platform :mri do
|
35
35
|
gem 'therubyracer'
|
36
|
-
gem 'bluecloth'
|
36
|
+
gem 'bluecloth' if ENV['BLUECLOTH']
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Tilt [![Build Status](https://secure.travis-ci.org/rtomayko/tilt.png)](http://tr
|
|
5
5
|
https://github.com/rtomayko/tilt/tree/tilt-1 for the current version.
|
6
6
|
|
7
7
|
Tilt is a thin interface over a bunch of different Ruby template engines in
|
8
|
-
an attempt to make their usage as generic possible. This is useful for web
|
8
|
+
an attempt to make their usage as generic as possible. This is useful for web
|
9
9
|
frameworks, static site generators, and other systems that support multiple
|
10
10
|
template engines but don't want to code for each of them individually.
|
11
11
|
|
@@ -61,6 +61,7 @@ These template engines ship with their own Tilt integration:
|
|
61
61
|
Embedded CoffeeScript sprockets
|
62
62
|
JST sprockets
|
63
63
|
Org-mode .org org-ruby (>= 0.6.2)
|
64
|
+
Handlebars .hbs, .handlebars tilt-handlebars
|
64
65
|
|
65
66
|
See [TEMPLATES.md][t] for detailed information on template engine
|
66
67
|
options and supported features.
|
data/docs/TEMPLATES.md
CHANGED
@@ -519,4 +519,5 @@ using this template engine within a threaded environment.
|
|
519
519
|
[discount]: http://www.pell.portland.or.us/~orc/Code/discount/ "Discount"
|
520
520
|
[rdiscount]: http://github.com/rtomayko/rdiscount/ "RDiscount"
|
521
521
|
[smartypants]: http://daringfireball.net/projects/smartypants/ "Smarty Pants"
|
522
|
+
[markdown]: http://en.wikipedia.org/wiki/Markdown "Markdown"
|
522
523
|
|
data/lib/tilt.rb
CHANGED
@@ -4,7 +4,7 @@ require 'tilt/template'
|
|
4
4
|
# Namespace for Tilt. This module is not intended to be included anywhere.
|
5
5
|
module Tilt
|
6
6
|
# Current version.
|
7
|
-
VERSION = '2.0.0
|
7
|
+
VERSION = '2.0.0'
|
8
8
|
|
9
9
|
@default_mapping = Mapping.new
|
10
10
|
|
@@ -131,5 +131,7 @@ module Tilt
|
|
131
131
|
register_lazy :YajlTemplate, 'tilt/yajl', 'yajl'
|
132
132
|
|
133
133
|
# External template engines
|
134
|
-
register_lazy 'Slim::Template',
|
134
|
+
register_lazy 'Slim::Template', 'slim', 'slim'
|
135
|
+
register_lazy 'Tilt::HandlebarsTemplate', 'tilt/handlebars', 'handlebars', 'hbs'
|
136
|
+
register_lazy 'Tilt::OrgTemplate', 'org-ruby', 'org'
|
135
137
|
end
|
data/lib/tilt/mapping.rb
CHANGED
@@ -63,7 +63,7 @@ module Tilt
|
|
63
63
|
# Registrers a lazy template implementation by file extension. You
|
64
64
|
# can have multiple lazy template implementations defined on the
|
65
65
|
# same file extension, in which case the template implementation
|
66
|
-
# defined *last* will be
|
66
|
+
# defined *last* will be attempted loaded *first*.
|
67
67
|
#
|
68
68
|
# @param class_name [String] Class name of a template class.
|
69
69
|
# @param file [String] Filename where the template class is defined.
|
@@ -100,8 +100,13 @@ module Tilt
|
|
100
100
|
# mapping.register MyEngine::Template, 'mt'
|
101
101
|
# mapping['index.mt'] # => MyEngine::Template
|
102
102
|
def register(template_class, *extensions)
|
103
|
+
if template_class.respond_to?(:to_str)
|
104
|
+
# Support register(ext, template_class) too
|
105
|
+
extensions, template_class = [template_class], extensions[0]
|
106
|
+
end
|
107
|
+
|
103
108
|
extensions.each do |ext|
|
104
|
-
@template_map[ext] = template_class
|
109
|
+
@template_map[ext.to_s] = template_class
|
105
110
|
end
|
106
111
|
end
|
107
112
|
|
@@ -171,6 +176,19 @@ module Tilt
|
|
171
176
|
templates
|
172
177
|
end
|
173
178
|
|
179
|
+
# Finds the extensions the template class has been registered under.
|
180
|
+
# @param [template class] template_class
|
181
|
+
def extensions_for(template_class)
|
182
|
+
res = []
|
183
|
+
template_map.each do |ext, klass|
|
184
|
+
res << ext if template_class == klass
|
185
|
+
end
|
186
|
+
lazy_map.each do |ext, choices|
|
187
|
+
res << ext if choices.any? { |klass, file| template_class.to_s == klass }
|
188
|
+
end
|
189
|
+
res
|
190
|
+
end
|
191
|
+
|
174
192
|
private
|
175
193
|
|
176
194
|
def lazy?(ext)
|
data/lib/tilt/template.rb
CHANGED
@@ -58,7 +58,9 @@ module Tilt
|
|
58
58
|
when arg.respond_to?(:to_int) ; @line = arg.to_int
|
59
59
|
when arg.respond_to?(:to_hash) ; @options = arg.to_hash.dup
|
60
60
|
when arg.respond_to?(:path) ; @file = arg.path
|
61
|
-
|
61
|
+
when arg.respond_to?(:to_path) ; @file = arg.to_path
|
62
|
+
else raise TypeError, "Can't load the template file. Pass a string with a path " +
|
63
|
+
"or an object that responds to 'to_str', 'path' or 'to_path'"
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
data/test/test_helper.rb
CHANGED
@@ -44,6 +44,16 @@ module Tilt
|
|
44
44
|
refute @mapping.registered?('baz')
|
45
45
|
end
|
46
46
|
|
47
|
+
test "#extensions_for" do
|
48
|
+
@mapping.register(Stub, 'foo', 'bar')
|
49
|
+
assert_equal ['foo', 'bar'].sort, @mapping.extensions_for(Stub).sort
|
50
|
+
end
|
51
|
+
|
52
|
+
test "supports old-style #register" do
|
53
|
+
@mapping.register('foo', Stub)
|
54
|
+
assert_equal Stub, @mapping['foo']
|
55
|
+
end
|
56
|
+
|
47
57
|
context "lazy with one template class" do
|
48
58
|
setup do
|
49
59
|
@mapping.register_lazy('MyTemplate', 'my_template', 'mt')
|
@@ -57,6 +67,10 @@ module Tilt
|
|
57
67
|
assert @mapping.registered?('mt')
|
58
68
|
end
|
59
69
|
|
70
|
+
test "#extensions_for" do
|
71
|
+
assert_equal ['mt'], @mapping.extensions_for('MyTemplate')
|
72
|
+
end
|
73
|
+
|
60
74
|
test "basic lookup" do
|
61
75
|
req = proc do |file|
|
62
76
|
assert_equal 'my_template', file
|
data/test/tilt_markdown_test.rb
CHANGED
@@ -67,11 +67,6 @@ module MarkdownTests
|
|
67
67
|
html = nrender "Hello ``World'' -- This is --- a test ...", :smartypants => false
|
68
68
|
assert_equal "<p>Hello ``World'' -- This is --- a test ...</p>", html
|
69
69
|
end
|
70
|
-
|
71
|
-
def test_smarty_pants_true
|
72
|
-
html = nrender "Hello ``World'' -- This is --- a test ...", :smartypants => true
|
73
|
-
assert_equal "<p>Hello “World” — This is —– a test …</p>", html
|
74
|
-
end
|
75
70
|
end
|
76
71
|
|
77
72
|
begin
|
@@ -80,6 +75,11 @@ begin
|
|
80
75
|
class MarkdownRDiscountTest < Minitest::Test
|
81
76
|
include MarkdownTests
|
82
77
|
template Tilt::RDiscountTemplate
|
78
|
+
|
79
|
+
def test_smarty_pants_true
|
80
|
+
html = nrender "Hello ``World'' -- This is --- a test ...", :smartypants => true
|
81
|
+
assert_equal "<p>Hello “World” – This is — a test …</p>", html
|
82
|
+
end
|
83
83
|
end
|
84
84
|
rescue LoadError => boom
|
85
85
|
# It should already be warned in the main tests
|
@@ -121,6 +121,11 @@ begin
|
|
121
121
|
class MarkdownBlueClothTest < Minitest::Test
|
122
122
|
include MarkdownTests
|
123
123
|
template Tilt::BlueClothTemplate
|
124
|
+
|
125
|
+
def test_smarty_pants_true
|
126
|
+
html = nrender "Hello ``World'' -- This is --- a test ...", :smartypants => true
|
127
|
+
assert_equal "<p>Hello “World” — This is —– a test …</p>", html
|
128
|
+
end
|
124
129
|
end
|
125
130
|
rescue LoadError => boom
|
126
131
|
# It should already be warned in the main tests
|
@@ -137,7 +142,6 @@ begin
|
|
137
142
|
# Smarty Pants is *always* on, but doesn't support it fully
|
138
143
|
undef test_smarty_pants
|
139
144
|
undef test_smarty_pants_false
|
140
|
-
undef test_smarty_pants_true
|
141
145
|
end
|
142
146
|
rescue LoadError => boom
|
143
147
|
# It should already be warned in the main tests
|
@@ -155,7 +159,6 @@ begin
|
|
155
159
|
# Doesn't support Smarty Pants, and even fails on ``Foobar''
|
156
160
|
undef test_smarty_pants
|
157
161
|
undef test_smarty_pants_false
|
158
|
-
undef test_smarty_pants_true
|
159
162
|
# Smart Quotes is always on
|
160
163
|
undef test_smart_quotes
|
161
164
|
undef test_smart_quotes_false
|
@@ -17,18 +17,18 @@ begin
|
|
17
17
|
|
18
18
|
test "preparing and evaluating templates on #render" do
|
19
19
|
template = Tilt::MarukuTemplate.new { |t| "# Hello World!" }
|
20
|
-
assert_equal "<h1 id
|
20
|
+
assert_equal "<h1 id=\"hello_world\">Hello World!</h1>", template.render.strip
|
21
21
|
end
|
22
22
|
|
23
23
|
test "can be rendered more than once" do
|
24
24
|
template = Tilt::MarukuTemplate.new { |t| "# Hello World!" }
|
25
|
-
3.times { assert_equal "<h1 id
|
25
|
+
3.times { assert_equal "<h1 id=\"hello_world\">Hello World!</h1>", template.render.strip }
|
26
26
|
end
|
27
27
|
|
28
28
|
test "removes HTML when :filter_html is set" do
|
29
29
|
template = Tilt::MarukuTemplate.new(:filter_html => true) { |t|
|
30
30
|
"HELLO <blink>WORLD</blink>" }
|
31
|
-
assert_equal "<p>HELLO </p>", template.render
|
31
|
+
assert_equal "<p>HELLO </p>", template.render.strip
|
32
32
|
end
|
33
33
|
end
|
34
34
|
rescue LoadError => boom
|
@@ -28,7 +28,7 @@ begin
|
|
28
28
|
test "smartypants when :smart is set" do
|
29
29
|
template = Tilt::RDiscountTemplate.new(:smart => true) { |t|
|
30
30
|
"OKAY -- 'Smarty Pants'" }
|
31
|
-
assert_equal "<p>OKAY &
|
31
|
+
assert_equal "<p>OKAY – ‘Smarty Pants’</p>\n",
|
32
32
|
template.render
|
33
33
|
end
|
34
34
|
|
data/test/tilt_template_test.rb
CHANGED
@@ -32,6 +32,13 @@ class TiltTemplateTest < Minitest::Test
|
|
32
32
|
assert_equal File.basename(tempfile.path), inst.basename
|
33
33
|
end
|
34
34
|
|
35
|
+
test "initializing with a pathname" do
|
36
|
+
tempfile = Tempfile.new('tilt_template_test')
|
37
|
+
pathname = Pathname.new(tempfile.path)
|
38
|
+
inst = MockTemplate.new(pathname)
|
39
|
+
assert_equal File.basename(tempfile.path), inst.basename
|
40
|
+
end
|
41
|
+
|
35
42
|
class SillyHash < Hash
|
36
43
|
def path(arg)
|
37
44
|
end
|
data/tilt.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'tilt'
|
6
|
-
s.version = '2.0.0
|
7
|
-
s.date = '2013-
|
6
|
+
s.version = '2.0.0'
|
7
|
+
s.date = '2013-11-30'
|
8
8
|
|
9
9
|
s.description = "Generic interface to multiple Ruby template engines"
|
10
10
|
s.summary = s.description
|
@@ -76,7 +76,7 @@ Gem::Specification.new do |s|
|
|
76
76
|
test/tilt_lesstemplate_test.less
|
77
77
|
test/tilt_lesstemplate_test.rb
|
78
78
|
test/tilt_liquidtemplate_test.rb
|
79
|
-
test/
|
79
|
+
test/tilt_mapping_test.rb
|
80
80
|
test/tilt_markaby_test.rb
|
81
81
|
test/tilt_markdown_test.rb
|
82
82
|
test/tilt_marukutemplate_test.rb
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tilt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Tomayko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generic interface to multiple Ruby template engines
|
14
14
|
email: r@tomayko.com
|
@@ -78,7 +78,7 @@ files:
|
|
78
78
|
- test/tilt_lesstemplate_test.less
|
79
79
|
- test/tilt_lesstemplate_test.rb
|
80
80
|
- test/tilt_liquidtemplate_test.rb
|
81
|
-
- test/
|
81
|
+
- test/tilt_mapping_test.rb
|
82
82
|
- test/tilt_markaby_test.rb
|
83
83
|
- test/tilt_markdown_test.rb
|
84
84
|
- test/tilt_marukutemplate_test.rb
|
@@ -117,12 +117,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
119
|
requirements:
|
120
|
-
- - '
|
120
|
+
- - '>='
|
121
121
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
122
|
+
version: '0'
|
123
123
|
requirements: []
|
124
124
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.0.
|
125
|
+
rubygems_version: 2.0.3
|
126
126
|
signing_key:
|
127
127
|
specification_version: 2
|
128
128
|
summary: Generic interface to multiple Ruby template engines
|
@@ -142,6 +142,7 @@ test_files:
|
|
142
142
|
- test/tilt_kramdown_test.rb
|
143
143
|
- test/tilt_lesstemplate_test.rb
|
144
144
|
- test/tilt_liquidtemplate_test.rb
|
145
|
+
- test/tilt_mapping_test.rb
|
145
146
|
- test/tilt_markaby_test.rb
|
146
147
|
- test/tilt_markdown_test.rb
|
147
148
|
- test/tilt_marukutemplate_test.rb
|