tilt 1.2 → 1.3.1
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/README.md +54 -24
- data/TEMPLATES.md +250 -175
- data/lib/tilt/builder.rb +40 -0
- data/lib/tilt/coffee.rb +50 -0
- data/lib/tilt/creole.rb +28 -0
- data/lib/tilt/css.rb +68 -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 +131 -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.rb +102 -805
- data/test/tilt_blueclothtemplate_test.rb +11 -25
- data/test/tilt_buildertemplate_test.rb +16 -1
- data/test/tilt_coffeescripttemplate_test.rb +37 -1
- data/test/tilt_creoletemplate_test.rb +24 -0
- data/test/tilt_erbtemplate_test.rb +23 -19
- data/test/tilt_erubistemplate_test.rb +17 -2
- data/test/tilt_fallback_test.rb +122 -0
- data/test/tilt_hamltemplate_test.rb +9 -4
- data/test/tilt_kramdown_test.rb +42 -0
- data/test/tilt_lesstemplate_test.rb +5 -0
- data/test/tilt_liquidtemplate_test.rb +5 -0
- data/test/tilt_markaby_test.rb +5 -0
- data/test/tilt_markdown_test.rb +149 -0
- data/test/tilt_marukutemplate_test.rb +48 -0
- data/test/tilt_nokogiritemplate_test.rb +20 -7
- data/test/tilt_radiustemplate_test.rb +5 -0
- data/test/tilt_rdiscounttemplate_test.rb +21 -6
- data/test/tilt_rdoctemplate_test.rb +6 -1
- data/test/tilt_redcarpettemplate_test.rb +55 -0
- data/test/tilt_redclothtemplate_test.rb +4 -0
- data/test/tilt_sasstemplate_test.rb +21 -0
- data/test/tilt_stringtemplate_test.rb +15 -3
- data/test/tilt_template_test.rb +6 -0
- data/tilt.gemspec +28 -7
- metadata +105 -7
data/README.md
CHANGED
|
@@ -21,22 +21,29 @@ 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) .creole creole
|
|
40
47
|
|
|
41
48
|
These template engines ship with their own Tilt integration:
|
|
42
49
|
|
|
@@ -116,7 +123,7 @@ classes based on those associations.
|
|
|
116
123
|
The `Tilt::register` method associates a filename pattern with a specific
|
|
117
124
|
template implementation. To use ERB for files ending in a `.bar` extension:
|
|
118
125
|
|
|
119
|
-
>> Tilt.register 'bar'
|
|
126
|
+
>> Tilt.register Tilt::ERBTemplate, 'bar'
|
|
120
127
|
>> Tilt.new('views/foo.bar')
|
|
121
128
|
=> #<Tilt::ERBTemplate @file="views/foo.bar" ...>
|
|
122
129
|
|
|
@@ -131,7 +138,7 @@ It's also possible to register template file mappings that are more specific
|
|
|
131
138
|
than a file extension. To use Erubis for `bar.erb` but ERB for all other `.erb`
|
|
132
139
|
files:
|
|
133
140
|
|
|
134
|
-
>> Tilt.register 'bar.erb'
|
|
141
|
+
>> Tilt.register Tilt::ErubisTemplate, 'bar.erb'
|
|
135
142
|
>> Tilt.new('views/foo.erb')
|
|
136
143
|
=> Tilt::ERBTemplate
|
|
137
144
|
>> Tilt.new('views/bar.erb')
|
|
@@ -147,14 +154,37 @@ mappings:
|
|
|
147
154
|
3. `html.erb`
|
|
148
155
|
4. `erb`
|
|
149
156
|
|
|
150
|
-
|
|
151
|
-
|
|
157
|
+
### Fallback mode
|
|
158
|
+
|
|
159
|
+
If there are more than one template class registered for a file extension, Tilt
|
|
160
|
+
will automatically try to load the version that works on your machine:
|
|
161
|
+
|
|
162
|
+
1. If any of the template engines has been loaded already: Use that one.
|
|
163
|
+
2. If not, it will try to initialize each of the classes with an empty template.
|
|
164
|
+
3. Tilt will use the first that doesn't raise an exception.
|
|
165
|
+
4. If however *all* of them failed, Tilt will raise the exception of the first
|
|
166
|
+
template engine, since that was the most preferred one.
|
|
167
|
+
|
|
168
|
+
Template classes that were registered *last* would be tried first. Because the
|
|
169
|
+
Markdown extensions are registered like this:
|
|
170
|
+
|
|
171
|
+
Tilt.register Tilt::BlueClothTemplate, 'md'
|
|
172
|
+
Tilt.register Tilt::RDiscountTemplate, 'md'
|
|
173
|
+
|
|
174
|
+
Tilt will first try RDiscount and then BlueCloth. You could say that RDiscount
|
|
175
|
+
has a *higher priority* than BlueCloth.
|
|
152
176
|
|
|
153
|
-
|
|
177
|
+
The fallback mode works nicely when you just need to render an ERB or Markdown
|
|
178
|
+
template, but if you depend on a specific implementation, you should use #prefer:
|
|
154
179
|
|
|
155
|
-
|
|
180
|
+
# Prefer BlueCloth for all its registered extensions (markdown, mkd, md)
|
|
181
|
+
Tilt.prefer Tilt::BlueClothTemplate
|
|
182
|
+
|
|
183
|
+
# Prefer Erubis for .erb only:
|
|
184
|
+
Tilt.prefer Tilt::ErubisTemplate, 'erb'
|
|
156
185
|
|
|
157
|
-
|
|
186
|
+
When a file extension has a preferred template class, Tilt will *always* use
|
|
187
|
+
that class, even if it raises an exception.
|
|
158
188
|
|
|
159
189
|
Template Compilation
|
|
160
190
|
--------------------
|
|
@@ -164,7 +194,7 @@ it on subsequent template invocations. Benchmarks show this yields a 5x-10x
|
|
|
164
194
|
performance increase over evaluating the Ruby source on each invocation.
|
|
165
195
|
|
|
166
196
|
Template compilation is currently supported for these template engines:
|
|
167
|
-
StringTemplate, ERB, Erubis, Haml, and Builder.
|
|
197
|
+
StringTemplate, ERB, Erubis, Haml, Nokogiri and Builder.
|
|
168
198
|
|
|
169
199
|
LICENSE
|
|
170
200
|
-------
|