tilt 1.2.2 → 1.3.3
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.
- data/Gemfile +2 -0
- data/README.md +59 -24
- data/TEMPLATES.md +252 -175
- data/lib/tilt/builder.rb +40 -0
- data/lib/tilt/coffee.rb +50 -0
- data/lib/tilt/css.rb +72 -0
- data/lib/tilt/erb.rb +110 -0
- data/lib/tilt/haml.rb +64 -0
- data/lib/tilt/liquid.rb +41 -0
- data/lib/tilt/markaby.rb +52 -0
- data/lib/tilt/markdown.rb +190 -0
- data/lib/tilt/nokogiri.rb +43 -0
- data/lib/tilt/radius.rb +51 -0
- data/lib/tilt/rdoc.rb +32 -0
- data/lib/tilt/string.rb +21 -0
- data/lib/tilt/template.rb +285 -0
- data/lib/tilt/textile.rb +25 -0
- data/lib/tilt/wiki.rb +50 -0
- data/lib/tilt/yajl.rb +94 -0
- data/lib/tilt.rb +105 -816
- data/test/tilt_blueclothtemplate_test.rb +6 -25
- data/test/tilt_coffeescripttemplate_test.rb +32 -1
- data/test/tilt_compilesite_test.rb +1 -1
- data/test/tilt_creoletemplate_test.rb +28 -0
- data/test/tilt_erbtemplate_test.rb +18 -19
- data/test/tilt_erubistemplate_test.rb +12 -2
- data/test/tilt_fallback_test.rb +122 -0
- data/test/tilt_hamltemplate_test.rb +4 -4
- data/test/tilt_kramdown_test.rb +42 -0
- data/test/tilt_lesstemplate_test.rb +3 -2
- data/test/tilt_markdown_test.rb +161 -0
- data/test/tilt_marukutemplate_test.rb +48 -0
- data/test/tilt_nokogiritemplate_test.rb +11 -0
- data/test/tilt_radiustemplate_test.rb +3 -3
- data/test/tilt_rdiscounttemplate_test.rb +16 -6
- data/test/tilt_redcarpettemplate_test.rb +59 -0
- data/test/tilt_sasstemplate_test.rb +0 -1
- data/test/tilt_stringtemplate_test.rb +10 -3
- data/test/tilt_template_test.rb +6 -0
- data/test/tilt_wikiclothtemplate_test.rb +32 -0
- data/test/tilt_yajltemplate_test.rb +92 -0
- data/tilt.gemspec +39 -8
- metadata +276 -150
data/Gemfile
ADDED
data/README.md
CHANGED
|
@@ -21,28 +21,40 @@ template engines included in the distribution.
|
|
|
21
21
|
|
|
22
22
|
Support for these template engines is included with the package:
|
|
23
23
|
|
|
24
|
-
ENGINE FILE EXTENSIONS
|
|
25
|
-
--------------------------
|
|
26
|
-
ERB .erb
|
|
27
|
-
Interpolated String .str
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
24
|
+
ENGINE FILE EXTENSIONS REQUIRED LIBRARIES
|
|
25
|
+
-------------------------- ----------------------- ----------------------------
|
|
26
|
+
ERB .erb, .rhtml none (included ruby stdlib)
|
|
27
|
+
Interpolated String .str none (included ruby core)
|
|
28
|
+
Erubis .erb, .rhtml, .erubis erubis
|
|
29
|
+
Haml .haml haml
|
|
30
|
+
Sass .sass haml (< 3.1) or sass (>= 3.1)
|
|
31
|
+
Scss .scss haml (< 3.1) or sass (>= 3.1)
|
|
32
|
+
Less CSS .less less
|
|
33
|
+
Builder .builder builder
|
|
34
|
+
Liquid .liquid liquid
|
|
35
|
+
RDiscount .markdown, .mkd, .md rdiscount
|
|
36
|
+
Redcarpet .markdown, .mkd, .md redcarpet
|
|
37
|
+
BlueCloth .markdown, .mkd, .md bluecloth
|
|
38
|
+
Kramdown .markdown, .mkd, .md kramdown
|
|
39
|
+
Maruku .markdown, .mkd, .md maruku
|
|
40
|
+
RedCloth .textile redcloth
|
|
41
|
+
RDoc .rdoc rdoc
|
|
42
|
+
Radius .radius radius
|
|
43
|
+
Markaby .mab markaby
|
|
44
|
+
Nokogiri .nokogiri nokogiri
|
|
45
|
+
CoffeeScript .coffee coffee-script (+ javascript)
|
|
46
|
+
Creole (Wiki markup) .wiki, .creole creole
|
|
47
|
+
WikiCloth (Wiki markup) .wiki, .mediawiki, .mw wikicloth
|
|
48
|
+
Yajl .yajl yajl-ruby
|
|
40
49
|
|
|
41
50
|
These template engines ship with their own Tilt integration:
|
|
42
51
|
|
|
43
52
|
ENGINE FILE EXTENSIONS REQUIRED LIBRARIES
|
|
44
53
|
-------------------------- ----------------- ----------------------------
|
|
45
54
|
Slim .slim slim (>= 0.7)
|
|
55
|
+
Embedded JavaScript sprockets
|
|
56
|
+
Embedded CoffeeScript sprockets
|
|
57
|
+
JST sprockets
|
|
46
58
|
|
|
47
59
|
See [TEMPLATES.md][t] for detailed information on template engine
|
|
48
60
|
options and supported features.
|
|
@@ -116,7 +128,7 @@ classes based on those associations.
|
|
|
116
128
|
The `Tilt::register` method associates a filename pattern with a specific
|
|
117
129
|
template implementation. To use ERB for files ending in a `.bar` extension:
|
|
118
130
|
|
|
119
|
-
>> Tilt.register 'bar'
|
|
131
|
+
>> Tilt.register Tilt::ERBTemplate, 'bar'
|
|
120
132
|
>> Tilt.new('views/foo.bar')
|
|
121
133
|
=> #<Tilt::ERBTemplate @file="views/foo.bar" ...>
|
|
122
134
|
|
|
@@ -131,7 +143,7 @@ It's also possible to register template file mappings that are more specific
|
|
|
131
143
|
than a file extension. To use Erubis for `bar.erb` but ERB for all other `.erb`
|
|
132
144
|
files:
|
|
133
145
|
|
|
134
|
-
>> Tilt.register 'bar.erb'
|
|
146
|
+
>> Tilt.register Tilt::ErubisTemplate, 'bar.erb'
|
|
135
147
|
>> Tilt.new('views/foo.erb')
|
|
136
148
|
=> Tilt::ERBTemplate
|
|
137
149
|
>> Tilt.new('views/bar.erb')
|
|
@@ -147,14 +159,37 @@ mappings:
|
|
|
147
159
|
3. `html.erb`
|
|
148
160
|
4. `erb`
|
|
149
161
|
|
|
150
|
-
|
|
151
|
-
|
|
162
|
+
### Fallback mode
|
|
163
|
+
|
|
164
|
+
If there are more than one template class registered for a file extension, Tilt
|
|
165
|
+
will automatically try to load the version that works on your machine:
|
|
166
|
+
|
|
167
|
+
1. If any of the template engines has been loaded already: Use that one.
|
|
168
|
+
2. If not, it will try to initialize each of the classes with an empty template.
|
|
169
|
+
3. Tilt will use the first that doesn't raise an exception.
|
|
170
|
+
4. If however *all* of them failed, Tilt will raise the exception of the first
|
|
171
|
+
template engine, since that was the most preferred one.
|
|
172
|
+
|
|
173
|
+
Template classes that were registered *last* would be tried first. Because the
|
|
174
|
+
Markdown extensions are registered like this:
|
|
175
|
+
|
|
176
|
+
Tilt.register Tilt::BlueClothTemplate, 'md'
|
|
177
|
+
Tilt.register Tilt::RDiscountTemplate, 'md'
|
|
178
|
+
|
|
179
|
+
Tilt will first try RDiscount and then BlueCloth. You could say that RDiscount
|
|
180
|
+
has a *higher priority* than BlueCloth.
|
|
152
181
|
|
|
153
|
-
|
|
182
|
+
The fallback mode works nicely when you just need to render an ERB or Markdown
|
|
183
|
+
template, but if you depend on a specific implementation, you should use #prefer:
|
|
154
184
|
|
|
155
|
-
|
|
185
|
+
# Prefer BlueCloth for all its registered extensions (markdown, mkd, md)
|
|
186
|
+
Tilt.prefer Tilt::BlueClothTemplate
|
|
187
|
+
|
|
188
|
+
# Prefer Erubis for .erb only:
|
|
189
|
+
Tilt.prefer Tilt::ErubisTemplate, 'erb'
|
|
156
190
|
|
|
157
|
-
|
|
191
|
+
When a file extension has a preferred template class, Tilt will *always* use
|
|
192
|
+
that class, even if it raises an exception.
|
|
158
193
|
|
|
159
194
|
Template Compilation
|
|
160
195
|
--------------------
|
|
@@ -164,7 +199,7 @@ it on subsequent template invocations. Benchmarks show this yields a 5x-10x
|
|
|
164
199
|
performance increase over evaluating the Ruby source on each invocation.
|
|
165
200
|
|
|
166
201
|
Template compilation is currently supported for these template engines:
|
|
167
|
-
StringTemplate, ERB, Erubis, Haml, and
|
|
202
|
+
StringTemplate, ERB, Erubis, Haml, Nokogiri, Builder and Yajl.
|
|
168
203
|
|
|
169
204
|
LICENSE
|
|
170
205
|
-------
|