tilt 1.2.2 → 1.3.2

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/TEMPLATES.md CHANGED
@@ -1,65 +1,123 @@
1
1
  Tilt Templates
2
2
  ==============
3
3
 
4
+ (See <https://github.com/rtomayko/tilt/blob/master/TEMPLATES.md> for a rendered,
5
+ HTML-version of this file).
6
+
4
7
  While all Tilt templates use the same basic interface for template loading and
5
8
  evaluation, each varies in its capabilities and available options. Detailed
6
9
  documentation on each supported template engine is provided below.
7
10
 
8
- * [ERB](#erb) - `Tilt::ERBTemplate`
11
+ There are also some file extensions that have several implementations
12
+ (currently ERB and Markdown). These template classes have certain features
13
+ which are guaranteed to work across all the implementations. If you wish to be
14
+ compatible with all of these template classes, you should only depend on the
15
+ cross-implementation features.
16
+
17
+ * [ERB](#erb) - Generic ERB implementation (backed by erb.rb or Erubis)
18
+ * [erb.rb](#erbrb) - `Tilt::ERBTemplate`
9
19
  * [Erubis](#erubis) - `Tilt::ErubisTemplate`
10
20
  * [Haml](#haml) - `Tilt::HamlTemplate`
11
21
  * [Liquid](#liquid) - `Tilt::LiquidTemplate`
22
+ * Nokogiri - `Tilt::NokogiriTemplate`
23
+ * Builder - `Tilt::BuilderTemplate`
24
+ * Markaby - `Tilt::MarkabyTemplate`
25
+ * [Radius](#radius) - `Tilt::RadiusTemplate`
12
26
 
13
- Tilt includes support for CSS processors like [lesscss](http://lesscss.org)
14
- and [sass](http://sass-lang.com/), in addition, it also supports simple
15
- text formats.
27
+ Tilt also includes support for CSS processors like [LessCSS][lesscss] and
28
+ [Sass][sass], [CoffeeScript][coffee-script] and some simple text formats.
16
29
 
17
30
  * Less - `Tilt::LessTemplate`
18
31
  * Sass - `Tilt::SassTemplate`
19
- * [Markdown](#markdown) - `Tilt::RDiscountTemplate`
32
+ * Scss - `Tilt::ScssTemplate`
33
+ * CoffeeScript - `Tilt::CoffeeScriptTemplate`
34
+ * [Textile](#redcloth) - `Tilt::RedClothTemplate`
35
+ * Creole - `Tilt::CreoleTemplate`
20
36
  * [RDoc](#rdoc) - `Tilt::RDocTemplate`
21
37
 
38
+ Tilt has extensive support for Markdown, backed by one of four different
39
+ implementations (depending on which are available on your system):
40
+
41
+ * [Markdown](#markdown) - Generic Markdown implementation
42
+ * [RDiscount](#rdiscount) - `Tilt::RDiscountTemplate`
43
+ * Redcarpet - `Tilt::RedcarpetTemplate`
44
+ * BlueCloth - `Tilt::BlueClothTemplate`
45
+ * Kramdown - `Tilt::KramdownTemplate`
46
+ * Maruku - `Tilt::MarukuTemplate`
47
+
22
48
  <a name='erb'></a>
23
49
  ERB (`erb`, `rhtml`)
24
50
  --------------------
25
51
 
26
- An easy to use but powerful templating system for Ruby.
52
+ ERB is a simple but powerful template languge for Ruby. In Tilt it's backed by
53
+ [Erubis](#erubis) (if installed on your system) or by [erb.rb](#erbrb) (which
54
+ is included in Ruby's standard library). This documentation applies to both
55
+ implementations.
27
56
 
28
57
  ### Example
29
58
 
30
59
  Hello <%= world %>!
31
-
60
+
32
61
  ### Usage
33
62
 
34
- The `Tilt::ERBTemplate` class is registered for all files ending in `.erb` or
35
- `.rhtml` by default. ERB templates support custom evaluation scopes and locals:
63
+ ERB templates support custom evaluation scopes and locals:
36
64
 
37
65
  >> require 'erb'
38
- >> template = Tilt.new('hello.html.erb', :trim => '<>')
39
- => #<Tilt::ERBTemplate @file='hello.html.erb'>
66
+ >> template = Tilt.new('hello.html.erb')
40
67
  >> template.render(self, :world => 'World!')
41
68
  => "Hello World!"
42
69
 
43
- Or, use the `Tilt::ERBTemplate` class directly to process strings:
70
+ Or, use `Tilt['erb']` directly to process strings:
44
71
 
45
- require 'erb'
46
- template = Tilt::ERBTemplate.new(nil, :trim => '<>') { "Hello <%= world %>!" }
72
+ template = Tilt['erb'].new { "Hello <%= world %>!" }
47
73
  template.render(self, :world => 'World!')
48
74
 
75
+ ### Options
76
+
77
+ #### `:trim => trim`
78
+
79
+ Omits newlines and spaces around certain lines (usually those that starts with
80
+ `<%` and ends with `%>`). There isn't a specification for how trimming in ERB
81
+ should work, so if you need more control over the whitespace, you should use
82
+ [erb.rb](#erbrb) or [Erubis](#erubis) directly.
83
+
84
+
85
+ #### `:outvar => '_erbout'`
86
+
87
+ The name of the variable used to accumulate template output. This can be
88
+ any valid Ruby expression but must be assignable. By default a local
89
+ variable named `_erbout` is used.
90
+
91
+ <a name='erbrb'></a>
92
+ erb.rb (`erb`, `rhtml`)
93
+ -----------------------
94
+
95
+ [ERB](#erb) implementation available in Ruby's standard library.
96
+
97
+ All the documentation of [ERB](#erb) applies in addition to the following:
98
+
99
+ ### Usage
100
+
101
+ The `Tilt::ERBTemplate` class is registered for all files ending in `.erb` or
102
+ `.rhtml` by default, but with a *lower* priority than ErubisTemplate. If you
103
+ specifically want to use ERB, it's recommended to use `#prefer`:
104
+
105
+ Tilt.prefer Tilt::ERBTemplate
106
+
49
107
  __NOTE:__ It's suggested that your program `require 'erb'` at load time when
50
108
  using this template engine within a threaded environment.
51
109
 
52
110
  ### Options
53
111
 
54
- #### `:trim => '-'`
112
+ #### `:trim => true`
55
113
 
56
- The ERB trim mode flags. This is a string consisting
57
- of any combination of the following characters:
114
+ The ERB trim mode flags. This is a string consisting of any combination of the
115
+ following characters:
58
116
 
59
117
  * `'>'` omits newlines for lines ending in `>`
60
118
  * `'<>'` omits newlines for lines starting with `<%` and ending in `%>`
61
- * `'-'` omits newlines for lines ending in `-%>`.
62
119
  * `'%'` enables processing of lines beginning with `%`
120
+ * `true` is an alias of `<>`
63
121
 
64
122
  #### `:safe => nil`
65
123
 
@@ -78,18 +136,23 @@ variable named `_erbout` is used.
78
136
 
79
137
 
80
138
  <a name='erubis'></a>
81
- Erubis (`erubis`)
82
- -----------------
139
+ Erubis (`erb`, `rhtml`, `erubis`)
140
+ ---------------------------------
83
141
 
84
- Erubis is a fast, secure, and very extensible implementation of eRuby.
142
+ [Erubis][erubis] is a fast, secure, and very extensible implementation of [ERB](#erb).
143
+
144
+ All the documentation of [ERB](#erb) applies in addition to the following:
85
145
 
86
146
  ### Usage
87
147
 
88
- To use Erubis instead of ERB for all `.erb` and `.rhtml` files, register
89
- the extensions as follows:
148
+ The `Tilt::ErubisTemplate` class is registered for all files ending in `.erb` or
149
+ `.rhtml` by default, but with a *higher* priority than `ERBTemplate`. If you
150
+ specifically want to use Erubis, it's recommended to use `#prefer`:
151
+
152
+ Tilt.prefer Tilt::ErubisTemplate
90
153
 
91
- Tilt.register 'erb', Tilt::ErubisTemplate
92
- Tilt.register 'rhtml', Tilt::ErubisTemplate
154
+ __NOTE:__ It's suggested that your program `require 'erubis'` at load time when
155
+ using this template engine within a threaded environment.
93
156
 
94
157
  ### Options
95
158
 
@@ -114,30 +177,26 @@ variable named `_erbout` is used.
114
177
 
115
178
  Set pattern for embedded Ruby code.
116
179
 
117
- See the [ERB](#erb) template documentation for examples, usage, and options.
118
-
119
180
  #### `:trim => true`
120
181
 
121
- Delete spaces around '<% %>'. (But, spaces around '<%= %>' are preserved.)
182
+ Delete spaces around `<% %>`. (But, spaces around `<%= %>` are preserved.)
122
183
 
123
184
  ### See also
124
185
 
125
- * [Erubis Home](http://www.kuwata-lab.com/erubis/)
186
+ * [Erubis Home][erubis]
126
187
  * [Erubis User's Guide](http://www.kuwata-lab.com/erubis/users-guide.html)
127
188
 
128
- __NOTE:__ It's suggested that your program `require 'erubis'` at load time when
129
- using this template engine within a threaded environment.
130
189
 
131
190
  <a name='haml'></a>
132
191
  Haml (`haml`)
133
192
  -------------
134
193
 
135
- Haml is a markup language that’s used to cleanly and simply describe the HTML of
136
- any web document without the use of inline code. Haml functions as a replacement
137
- for inline page templating systems such as PHP, ASP, and ERB, the templating
138
- language used in most Ruby on Rails applications. However, Haml avoids the
139
- need for explicitly coding HTML into the template, because it itself is a
140
- description of the HTML, with some code to generate dynamic content.
194
+ [Haml][haml] is a markup language that’s used to cleanly and simply describe
195
+ the HTML of any web document without the use of inline code. Haml functions as
196
+ a replacement for inline page templating systems such as PHP, ASP, and ERB, the
197
+ templating language used in most Ruby on Rails applications. However, Haml
198
+ avoids the need for explicitly coding HTML into the template, because it itself
199
+ is a description of the HTML, with some code to generate dynamic content.
141
200
  ([more](http://haml-lang.com/about.html))
142
201
 
143
202
 
@@ -184,74 +243,21 @@ using this template engine within a threaded environment.
184
243
 
185
244
  ### Options
186
245
 
187
- #### `:format => :xhtml`
188
-
189
- Determines the output format. The default is `:xhtml`. Other options are
190
- `:html4` and `:html5`, which are identical to `:xhtml` except there are no
191
- self-closing tags, the XML prolog is ignored and correct DOCTYPEs are generated.
192
-
193
- #### `:escape_html => false`
194
-
195
- Sets whether or not to escape HTML-sensitive characters in script. If this is
196
- true, `=` behaves like `&=;` otherwise, it behaves like `!=`. Note that if this
197
- is set, `!=` should be used for yielding to subtemplates and rendering partials.
198
- Defaults to false.
199
-
200
- #### `:ugly => false`
201
-
202
- If set to true, Haml makes no attempt to properly indent or format the HTML
203
- output. This causes the rendering to be done much quicker than it would
204
- otherwise, but makes viewing the source unpleasant. Defaults to false.
205
-
206
- #### `:suppress_eval => false`
207
-
208
- Whether or not attribute hashes and Ruby scripts designated by `=` or `~` should
209
- be evaluated. If this is true, said scripts are rendered as empty strings.
210
- Defaults to false.
211
-
212
- #### `:attr_wrapper => "'"`
213
-
214
- The character that should wrap element attributes. This defaults to `'` (an
215
- apostrophe). Characters of this type within the attributes will be escaped (e.g.
216
- by replacing them with `&apos;`) if the character is an apostrophe or a
217
- quotation mark.
218
-
219
- #### `:autoclose => %w[meta img link br hr input area param col base]`
220
-
221
- A list of tag names that should be automatically self-closed if they have no
222
- content. Defaults to `['meta', 'img', 'link', 'br', 'hr', 'input', 'area',
223
- 'param', 'col', 'base']`.
224
-
225
- #### `:preserve => %w[textarea pre]`
226
-
227
- A list of tag names that should automatically have their newlines preserved
228
- using the `Haml::Helpers#preserve` helper. This means that any content given on
229
- the same line as the tag will be preserved. For example, `%textarea= "Foo\nBar"`
230
- compiles to `<textarea>Foo&#x000A;Bar</textarea>`. Defaults to `['textarea',
231
- 'pre']`.
232
-
233
- #### `:encoding => 'utf-8'`
234
-
235
- The encoding to use for the HTML output. Only available in Ruby 1.9 or higher.
236
- This can be a string or an Encoding Object. Note that Haml does not
237
- automatically re-encode Ruby values; any strings coming from outside the
238
- application should be converted before being passed into the Haml template.
239
- Defaults to `Encoding.default_internal` or, if that's not set, `"utf-8"`.
246
+ Please see the [Haml Reference](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#options) for all available options.
240
247
 
241
248
  ### See also
242
249
 
243
250
  * [#haml.docs](http://haml-lang.com/docs.html)
244
251
  * [Haml Tutorial](http://haml-lang.com/tutorial.html)
245
252
  * [Haml Reference](http://haml-lang.com/docs/yardoc/HAML_REFERENCE.md.html)
246
- * [Whitespace Preservation](http://haml-lang.com/docs/yardoc/HAML_REFERENCE.md.html#whitespace_preservation)
247
253
 
248
254
 
249
255
  <a name='liquid'></a>
250
256
  Liquid (`liquid`)
251
257
  -----------------
252
258
 
253
- Liquid is for rendering safe templates which cannot affect the security
254
- of the server they are rendered on.
259
+ [Liquid][liquid] is for rendering safe templates which cannot affect the
260
+ security of the server they are rendered on.
255
261
 
256
262
  ### Example
257
263
 
@@ -289,7 +295,7 @@ default. Liquid templates support locals and objects that respond to
289
295
  Or, use `Tilt::LiquidTemplate` directly to process strings:
290
296
 
291
297
  >> require 'haml'
292
- >> template = Tilt::HamlTemplate.new { "<h1>Hello Liquid!</h1>" }
298
+ >> template = Tilt::LiquidTemplate.new { "<h1>Hello Liquid!</h1>" }
293
299
  => #<Tilt::LiquidTemplate @file=nil ...>
294
300
  >> template.render
295
301
  => "<h1>Hello Liquid!</h1>"
@@ -303,137 +309,208 @@ time when using this template engine within a threaded environment.
303
309
  * [Liquid Docs](http://liquid.rubyforge.org/)
304
310
  * GitHub: [tobi/liquid](http://github.com/tobi/liquid/)
305
311
 
306
- <a name='markdown'></a>
307
- Markdown (`markdown`, `md`, `mkd`)
308
- ----------------------------------
309
312
 
310
- Markdown is a lightweight markup language, created by John Gruber and
311
- Aaron Swartz. For any markup that is not covered by Markdown’s syntax,
312
- HTML is used. Marking up plain text with Markdown markup is easy and
313
- Markdown formatted texts are readable.
313
+ <a name='radius'></a>
314
+ Radius (`radius`)
315
+ -----------------
314
316
 
315
- Markdown formatted texts are converted to HTML with the [RDiscount][]
316
- engine, which is a Ruby extension over the fast [Discount][] C library.
317
+ [Radius][radius] is the template language used by [Radiant CMS][radiant]. It is
318
+ a tag language designed to be valid XML/HTML.
317
319
 
318
320
  ### Example
319
321
 
320
- Hello Markdown Templates
321
- ========================
322
-
323
- Hello World. This is a paragraph.
322
+ <html>
323
+ <body>
324
+ <h1><r:title /></h1>
325
+ <ul class="<r:type />">
326
+ <r:repeat times="3">
327
+ <li><r:hello />!</li>
328
+ </r:repeat>
329
+ </ul>
330
+ <r:yield />
331
+ </body>
332
+ </html>
324
333
 
325
334
  ### Usage
326
335
 
327
- To wrap a Markdown formatted document with a layout:
336
+ To render a template such as the one above.
328
337
 
329
- require 'erubis'
330
- require 'rdiscount'
331
- layout = Tilt::ErubisTemplate.new(nil, :pattern => '\{% %\}') do
332
- "<!doctype html><title></title>{%= yield %}"
333
- end
334
- data = Tilt::RDiscountTemplate.new { "# hello tilt" }
335
- layout.render { data.render }
336
- # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
338
+ scope = OpenStruct.new
339
+ scope.title = "Radius Example"
340
+ scope.hello = "Hello, World!"
337
341
 
338
- __NOTE:__ It's suggested that your program `require 'rdiscount'` at load time
339
- when using this template engine in a threaded environment.
342
+ require 'radius'
343
+ template = Tilt::RadiusTemplate.new('example.radius', :tag_prefix=>'r')
344
+ template.render(scope, :type=>'hlist'){ "Jackpot!" }
340
345
 
341
- ### Options
346
+ The result will be:
347
+
348
+ <html>
349
+ <body>
350
+ <h1>Radius Example</h1>
351
+ <ul class="hlist">
352
+ <li>Hello, World!</li>
353
+ <li>Hello, World!</li>
354
+ <li>Hello, World!</li>
355
+ </ul>
356
+ Jackpot!
357
+ </body>
358
+ </html>
342
359
 
343
- RDiscount supports a variety of flags that control its behavior:
360
+ ### See also
344
361
 
345
- #### `:smart => true|false`
362
+ * [Radius][radius]
363
+ * [Radiant CMS][radiant]
346
364
 
347
- Set `true` to enable [Smarty Pants](http://daringfireball.net/projects/smartypants/)
348
- style punctuation replacement.
349
365
 
350
- #### `:filter_html => true|false`
366
+ <a name='textile'></a>
367
+ Textile (`textile`)
368
+ -------------------
351
369
 
352
- Set `true` disallow raw HTML in Markdown contents. HTML is converted to
353
- literal text by escaping `<` characters.
370
+ Textile is a lightweight markup language originally developed by Dean Allen and
371
+ billed as a "humane Web text generator". Textile converts its marked-up text
372
+ input to valid, well-formed XHTML and also inserts character entity references
373
+ for apostrophes, opening and closing single and double quotation marks,
374
+ ellipses and em dashes.
354
375
 
355
- ### See also
376
+ Textile formatted texts are converted to HTML with the [RedCloth][redcloth]
377
+ engine, which is a Ruby extension written in C.
356
378
 
357
- * [Markdown Syntax Documentation][markdown syntax]
358
- * GitHub: [rtomayko/rdiscount][rdiscount]
379
+ ### Example
359
380
 
360
- [discount]: http://www.pell.portland.or.us/~orc/Code/discount/ "Discount"
361
- [rdiscount]: http://github.com/rtomayko/rdiscount/ "RDiscount"
362
- [markdown syntax]: (http://daringfireball.net/projects/markdown/syntax/) "Markdown Syntax"
381
+ h1. Hello Textile Templates
382
+
383
+ Hello World. This is a paragraph.
384
+
385
+ ### Usage
386
+
387
+ __NOTE:__ It's suggested that your program `require 'redcloth'` at load time
388
+ when using this template engine in a threaded environment.
389
+
390
+ ### See Also
391
+
392
+ * [RedCloth][redcloth]
363
393
 
364
394
 
365
395
  <a name='rdoc'></a>
366
396
  RDoc (`rdoc`)
367
397
  -------------
368
398
 
369
- RDoc is the simple text markup system that comes with Ruby's standard
399
+ [RDoc][rdoc] is the simple text markup system that comes with Ruby's standard
370
400
  library.
371
401
 
402
+ ### Example
403
+
404
+ = Hello RDoc Templates
405
+
406
+ Hello World. This is a paragraph.
407
+
372
408
  ### Usage
373
409
 
374
410
  __NOTE:__ It's suggested that your program `require 'rdoc/markup'` and
375
411
  `require 'rdoc/markup/to_html'` at load time when using this template
376
412
  engine in a threaded environment.
377
413
 
378
- ### Example
414
+ ### See also
379
415
 
380
- = Hello RDoc Templates
416
+ * [RDoc][rdoc]
381
417
 
382
- Hello World. This is a paragraph.
383
418
 
384
- ### See also
419
+ <a name='markdown'></a>
420
+ Markdown (`markdown`, `md`, `mkd`)
421
+ ----------------------------------
385
422
 
386
- * [RDoc](http://rdoc.sourceforge.net/doc/index.html)
423
+ [Markdown][markdown] is a lightweight markup language, created by John Gruber
424
+ and Aaron Swartz. For any markup that is not covered by Markdown’s syntax, HTML
425
+ is used. Marking up plain text with Markdown markup is easy and Markdown
426
+ formatted texts are readable.
387
427
 
428
+ Markdown formatted texts are converted to HTML with one of these libraries:
388
429
 
389
- <a name='radius'></a>
390
- Radius (`radius`)
391
- -----------------
430
+ * [RDiscount](#rdiscount) - `Tilt::RDiscountTemplate`
431
+ * Redcarpet - `Tilt::RedcarpetTemplate`
432
+ * BlueCloth - `Tilt::BlueClothTemplate`
433
+ * Kramdown - `Tilt::KramdownTemplate`
434
+ * Maruku - `Tilt::MarukuTemplate`
392
435
 
393
- Radius is the template language used by Radiant CMS. It is a tag
394
- language designed to be valid XML/HTML.
436
+ Tilt will use fallback mode (as documented in the README) for determining which
437
+ library to use. RDiscount has highest priority - Maruku has lowest.
395
438
 
396
439
  ### Example
397
440
 
398
- <html>
399
- <body>
400
- <h1><r:title /></h1>
401
- <ul class="<r:type />">
402
- <r:repeat times="3">
403
- <li><r:hello />!</li>
404
- </r:repeat>
405
- </ul>
406
- <r:yield />
407
- </body>
408
- </html>
441
+ Hello Markdown Templates
442
+ ========================
443
+
444
+ Hello World. This is a paragraph.
409
445
 
410
446
  ### Usage
411
447
 
412
- To render a template such as the one above.
448
+ To wrap a Markdown formatted document with a layout:
413
449
 
414
- scope = OpenStruct.new
415
- scope.title = "Radius Example"
416
- scope.hello = "Hello, World!"
450
+ layout = Tilt['erb'].new do
451
+ "<!doctype html><title></title><%= yield %>"
452
+ end
453
+ data = Tilt['md'].new { "# hello tilt" }
454
+ layout.render { data.render }
455
+ # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
417
456
 
418
- require 'radius'
419
- template = Tilt::RadiusTemplate.new('example.radius', :tag_prefix=>'r')
420
- template.render(scope, :type=>'hlist'){ "Jackpot!" }
457
+ ### Options
421
458
 
422
- The result will be:
459
+ Every implementation of Markdown *should* support these options, but there are
460
+ some known problems with the Kramdown and Maruku engines.
423
461
 
424
- <html>
425
- <body>
426
- <h1>Radius Example</h1>
427
- <ul class="hlist">
428
- <li>Hello, World!</li>
429
- <li>Hello, World!</li>
430
- <li>Hello, World!</li>
431
- </ul>
432
- Jackpot!
433
- </body>
434
- </html>
462
+ #### `:smartypants => true|false`
463
+
464
+ Set `true` to enable [Smarty Pants][smartypants]
465
+ style punctuation replacement.
466
+
467
+ #### `:escape_html => true|false`
468
+
469
+ Set `true` disallow raw HTML in Markdown contents. HTML is converted to
470
+ literal text by escaping `<` characters.
435
471
 
436
472
  ### See also
437
473
 
438
- * [Radius](http://radius.rubyforge.org/)
439
- * [Radiant](http://radiantcms.org/)
474
+ * [Markdown Syntax Documentation](http://daringfireball.net/projects/markdown/syntax/)
475
+
476
+ <a name='rdiscount'></a>
477
+ RDiscount (`markdown`, `md`, `mkd`)
478
+ -----------------------------------
479
+
480
+ [Discount][discount] is an implementation of the Markdown markup language in C.
481
+ [RDiscount][rdiscount] is a Ruby wrapper around Discount.
482
+
483
+ All the documentation of [Markdown](#markdown) applies in addition to the following:
484
+
485
+ ### Usage
486
+
487
+ The `Tilt::RDiscountTemplate` class is registered for all files ending in
488
+ `.markdown`, `.md` or `.mkd` by default with the highest priority. If you
489
+ specifically want to use RDiscount, it's recommended to use `#prefer`:
490
+
491
+ Tilt.prefer Tilt::RDiscountTemplate
492
+
493
+ __NOTE:__ It's suggested that your program `require 'erubis'` at load time when
494
+ using this template engine within a threaded environment.
495
+
496
+ ### See also
497
+
498
+ * [Discount][discount]
499
+ * [RDiscount][rdiscount]
500
+ * GitHub: [rtomayko/rdiscount][rdiscount]
501
+
502
+
503
+ [lesscss]: http://lesscss.org/ "Less CSS"
504
+ [sass]: http://sass-lang.com/ "Sass"
505
+ [coffee-script]: http://jashkenas.github.com/coffee-script/ "Coffee Script"
506
+ [erubis]: http://www.kuwata-lab.com/erubis/ "Erubis"
507
+ [haml]: http://haml-lang.org/ "Haml"
508
+ [liquid]: http://www.liquidmarkup.org/ "Liquid"
509
+ [radius]: http://radius.rubyforge.org/ "Radius"
510
+ [radiant]: http://radiantcms.org/ "Radiant CMS"
511
+ [redcloth]: http://redcloth.org/ "RedCloth"
512
+ [rdoc]: http://rdoc.rubyforge.org/ "RDoc"
513
+ [discount]: http://www.pell.portland.or.us/~orc/Code/discount/ "Discount"
514
+ [rdiscount]: http://github.com/rtomayko/rdiscount/ "RDiscount"
515
+ [smartypants]: http://daringfireball.net/projects/smartypants/ "Smarty Pants"
516
+
@@ -0,0 +1,40 @@
1
+ require 'tilt/template'
2
+
3
+ module Tilt
4
+ # Builder template implementation. See:
5
+ # http://builder.rubyforge.org/
6
+ class BuilderTemplate < Template
7
+ self.default_mime_type = 'text/xml'
8
+
9
+ def self.engine_initialized?
10
+ defined? ::Builder
11
+ end
12
+
13
+ def initialize_engine
14
+ require_template_library 'builder'
15
+ end
16
+
17
+ def prepare; end
18
+
19
+ def evaluate(scope, locals, &block)
20
+ return super(scope, locals, &block) if data.respond_to?(:to_str)
21
+ xml = ::Builder::XmlMarkup.new(:indent => 2)
22
+ data.call(xml)
23
+ xml.target!
24
+ end
25
+
26
+ def precompiled_preamble(locals)
27
+ return super if locals.include? :xml
28
+ "xml = ::Builder::XmlMarkup.new(:indent => 2)\n#{super}"
29
+ end
30
+
31
+ def precompiled_postamble(locals)
32
+ "xml.target!"
33
+ end
34
+
35
+ def precompiled_template(locals)
36
+ data.to_str
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,50 @@
1
+ require 'tilt/template'
2
+
3
+ module Tilt
4
+ # CoffeeScript template implementation. See:
5
+ # http://coffeescript.org/
6
+ #
7
+ # CoffeeScript templates do not support object scopes, locals, or yield.
8
+ class CoffeeScriptTemplate < Template
9
+ self.default_mime_type = 'application/javascript'
10
+
11
+ @@default_bare = false
12
+
13
+ def self.default_bare
14
+ @@default_bare
15
+ end
16
+
17
+ def self.default_bare=(value)
18
+ @@default_bare = value
19
+ end
20
+
21
+ # DEPRECATED
22
+ def self.default_no_wrap
23
+ @@default_bare
24
+ end
25
+
26
+ # DEPRECATED
27
+ def self.default_no_wrap=(value)
28
+ @@default_bare = value
29
+ end
30
+
31
+ def self.engine_initialized?
32
+ defined? ::CoffeeScript
33
+ end
34
+
35
+ def initialize_engine
36
+ require_template_library 'coffee_script'
37
+ end
38
+
39
+ def prepare
40
+ if !options.key?(:bare) and !options.key?(:no_wrap)
41
+ options[:bare] = self.class.default_bare
42
+ end
43
+ end
44
+
45
+ def evaluate(scope, locals, &block)
46
+ @output ||= CoffeeScript.compile(data, options)
47
+ end
48
+ end
49
+ end
50
+