Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 515 lines (358 sloc) 14.981 kb
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
1 Tilt Templates
2 ==============
f7bcad2 @rtomayko starting in on template engine docs
authored
3
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
4 (See <https://github.com/rtomayko/tilt/blob/master/TEMPLATES.md> for a rendered,
5 HTML-version of this file).
6
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
7 While all Tilt templates use the same basic interface for template loading and
8 evaluation, each varies in its capabilities and available options. Detailed
9 documentation on each supported template engine is provided below.
10
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
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`
5d7b643 @rtomayko tidy up TEMPLATES documentation a bit
authored
19 * [Erubis](#erubis) - `Tilt::ErubisTemplate`
20 * [Haml](#haml) - `Tilt::HamlTemplate`
4eeaac4 @rtomayko add basic liquid docs
authored
21 * [Liquid](#liquid) - `Tilt::LiquidTemplate`
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
22 * Nokogiri - `Tilt::NokogiriTemplate`
23 * Builder - `Tilt::BuilderTemplate`
24 * Markaby - `Tilt::MarkabyTemplate`
25 * [Radius](#radius) - `Tilt::RadiusTemplate`
719b0c0 @rtomayko more whitespace errors benschwarz tsk tsk
authored
26
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
27 Tilt also includes support for CSS processors like [LessCSS][lesscss] and
28 [Sass][sass], [CoffeeScript][coffee-script] and some simple text formats.
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
29
7c28004 @benschwarz Did my homework for Mr Tomayko, the geography teacher.
benschwarz authored
30 * Less - `Tilt::LessTemplate`
31 * Sass - `Tilt::SassTemplate`
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
32 * Scss - `Tilt::ScssTemplate`
33 * CoffeeScript - `Tilt::CoffeeScriptTemplate`
34 * [Textile](#redcloth) - `Tilt::RedClothTemplate`
35 * Creole - `Tilt::CreoleTemplate`
23a141b @rtomayko RDocTemplate specs and docs
authored
36 * [RDoc](#rdoc) - `Tilt::RDocTemplate`
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
37
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
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 * BlueCloth - `Tilt::BlueClothTemplate`
44 * Kramdown - `Tilt::KramdownTemplate`
45 * Maruku - `Tilt::MarukuTemplate`
46
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
47 <a name='erb'></a>
f7bcad2 @rtomayko starting in on template engine docs
authored
48 ERB (`erb`, `rhtml`)
49 --------------------
50
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
51 ERB is a simple but powerful template languge for Ruby. In Tilt it's backed by
52 [Erubis](#erubis) (if installed on your system) or by [erb.rb](#erbrb) (which
53 is included in Ruby's standard library). This documentation applies to both
54 implementations.
f7bcad2 @rtomayko starting in on template engine docs
authored
55
56 ### Example
57
58 Hello <%= world %>!
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
59
f7bcad2 @rtomayko starting in on template engine docs
authored
60 ### Usage
61
b52ddae @judofyr Add documentation for fallback mode
judofyr authored
62 ERB templates support custom evaluation scopes and locals:
f7bcad2 @rtomayko starting in on template engine docs
authored
63
64 >> require 'erb'
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
65 >> template = Tilt.new('hello.html.erb')
f7bcad2 @rtomayko starting in on template engine docs
authored
66 >> template.render(self, :world => 'World!')
67 => "Hello World!"
68
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
69 Or, use `Tilt['erb']` directly to process strings:
f7bcad2 @rtomayko starting in on template engine docs
authored
70
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
71 template = Tilt['erb'].new { "Hello <%= world %>!" }
f7bcad2 @rtomayko starting in on template engine docs
authored
72 template.render(self, :world => 'World!')
73
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
74 ### Options
75
76 #### `:trim => trim`
77
78 Omits newlines and spaces around certain lines (usually those that starts with
79 `<%` and ends with `%>`). There isn't a specification for how trimming in ERB
80 should work, so if you need more control over the whitespace, you should use
81 [erb.rb](#erbrb) or [Erubis](#erubis) directly.
82
83
84 #### `:outvar => '_erbout'`
85
86 The name of the variable used to accumulate template output. This can be
87 any valid Ruby expression but must be assignable. By default a local
88 variable named `_erbout` is used.
89
90 <a name='erbrb'></a>
91 erb.rb (`erb`, `rhtml`)
92 -----------------------
93
94 [ERB](#erb) implementation available in Ruby's standard library.
95
96 All the documentation of [ERB](#erb) applies in addition to the following:
97
98 ### Usage
99
100 The `Tilt::ERBTemplate` class is registered for all files ending in `.erb` or
101 `.rhtml` by default, but with a *lower* priority than ErubisTemplate. If you
102 specifically want to use ERB, it's recommended to use `#prefer`:
103
104 Tilt.prefer Tilt::ERBTemplate
105
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
106 __NOTE:__ It's suggested that your program `require 'erb'` at load time when
107 using this template engine within a threaded environment.
108
f7bcad2 @rtomayko starting in on template engine docs
authored
109 ### Options
110
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
111 #### `:trim => true`
f7bcad2 @rtomayko starting in on template engine docs
authored
112
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
113 The ERB trim mode flags. This is a string consisting of any combination of the
114 following characters:
f7bcad2 @rtomayko starting in on template engine docs
authored
115
116 * `'>'` omits newlines for lines ending in `>`
117 * `'<>'` omits newlines for lines starting with `<%` and ending in `%>`
118 * `'%'` enables processing of lines beginning with `%`
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
119 * `true` is an alias of `<>`
f7bcad2 @rtomayko starting in on template engine docs
authored
120
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
121 #### `:safe => nil`
f7bcad2 @rtomayko starting in on template engine docs
authored
122
123 The `$SAFE` level; when set, ERB code will be run in a
124 separate thread with `$SAFE` set to the provided level.
125
e1ce6da @rtomayko document ERB/Erubis :outvar option
authored
126 #### `:outvar => '_erbout'`
127
128 The name of the variable used to accumulate template output. This can be
129 any valid Ruby expression but must be assignable. By default a local
130 variable named `_erbout` is used.
131
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
132 ### See also
133
134 * [ERB documentation](http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html)
135
136
137 <a name='erubis'></a>
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
138 Erubis (`erb`, `rhtml`, `erubis`)
139 ---------------------------------
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
140
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
141 [Erubis][erubis] is a fast, secure, and very extensible implementation of [ERB](#erb).
142
143 All the documentation of [ERB](#erb) applies in addition to the following:
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
144
145 ### Usage
146
b52ddae @judofyr Add documentation for fallback mode
judofyr authored
147 The `Tilt::ErubisTemplate` class is registered for all files ending in `.erb` or
148 `.rhtml` by default, but with a *higher* priority than `ERBTemplate`. If you
149 specifically want to use Erubis, it's recommended to use `#prefer`:
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
150
b52ddae @judofyr Add documentation for fallback mode
judofyr authored
151 Tilt.prefer Tilt::ErubisTemplate
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
152
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
153 __NOTE:__ It's suggested that your program `require 'erubis'` at load time when
154 using this template engine within a threaded environment.
155
e9782ef @wbzyl added Options section to Erubis
wbzyl authored
156 ### Options
157
4ee7afa @rtomayko document new erubis options in TEMPLATES.md
authored
158 #### `:engine_class => Erubis::Eruby`
e9782ef @wbzyl added Options section to Erubis
wbzyl authored
159
4ee7afa @rtomayko document new erubis options in TEMPLATES.md
authored
160 Allows you to specify a custom engine class to use instead of the
161 default which is `Erubis::Eruby`.
e9782ef @wbzyl added Options section to Erubis
wbzyl authored
162
4ee7afa @rtomayko document new erubis options in TEMPLATES.md
authored
163 #### `:escape_html => false`
e9782ef @wbzyl added Options section to Erubis
wbzyl authored
164
4ee7afa @rtomayko document new erubis options in TEMPLATES.md
authored
165 When `true`, `Erubis::EscapedEruby` will be used as the engine class
166 instead of the default. All content within `<%= %>` blocks will be
167 automatically html escaped.
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
168
e1ce6da @rtomayko document ERB/Erubis :outvar option
authored
169 #### `:outvar => '_erbout'`
170
171 The name of the variable used to accumulate template output. This can be
172 any valid Ruby expression but must be assignable. By default a local
173 variable named `_erbout` is used.
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
174
4ee7afa @rtomayko document new erubis options in TEMPLATES.md
authored
175 #### `:pattern => '<% %>'`
176
177 Set pattern for embedded Ruby code.
178
179 #### `:trim => true`
180
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
181 Delete spaces around `<% %>`. (But, spaces around `<%= %>` are preserved.)
4ee7afa @rtomayko document new erubis options in TEMPLATES.md
authored
182
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
183 ### See also
184
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
185 * [Erubis Home][erubis]
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
186 * [Erubis User's Guide](http://www.kuwata-lab.com/erubis/users-guide.html)
187
188
189 <a name='haml'></a>
190 Haml (`haml`)
191 -------------
192
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
193 [Haml][haml] is a markup language that’s used to cleanly and simply describe
194 the HTML of any web document without the use of inline code. Haml functions as
195 a replacement for inline page templating systems such as PHP, ASP, and ERB, the
196 templating language used in most Ruby on Rails applications. However, Haml
197 avoids the need for explicitly coding HTML into the template, because it itself
198 is a description of the HTML, with some code to generate dynamic content.
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
199 ([more](http://haml-lang.com/about.html))
200
201
202 ### Example
203
204 %html
205 %head
206 %title= @title
207 %body
208 %h1
209 Hello
210 = world + '!'
211
212 ### Usage
213
214 The `Tilt::HamlTemplate` class is registered for all files ending in `.haml`
215 by default. Haml templates support custom evaluation scopes and locals:
216
217 >> require 'haml'
218 >> template = Tilt.new('hello.haml')
219 => #<Tilt::HamlTemplate @file='hello.haml'>
220 >> @title = "Hello Haml!"
221 >> template.render(self, :world => 'Haml!')
222 => "
223 <html>
224 <head>
225 <title>Hello Haml!</title>
226 </head>
227 <body>
228 <h1>Hello Haml!</h1>
229 </body>
230 </html>"
231
232 Or, use the `Tilt::HamlTemplate` class directly to process strings:
233
234 >> require 'haml'
235 >> template = Tilt::HamlTemplate.new { "%h1= 'Hello Haml!'" }
236 => #<Tilt::HamlTemplate @file=nil ...>
237 >> template.render
238 => "<h1>Hello Haml!</h1>"
239
240 __NOTE:__ It's suggested that your program `require 'haml'` at load time when
241 using this template engine within a threaded environment.
242
243 ### Options
244
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
245 Please see the [Haml Reference](http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#options) for all available options.
2a4b2c0 @rtomayko add erubis, haml, and mustache docs to TEMPLATES.md
authored
246
247 ### See also
248
249 * [#haml.docs](http://haml-lang.com/docs.html)
250 * [Haml Tutorial](http://haml-lang.com/tutorial.html)
251 * [Haml Reference](http://haml-lang.com/docs/yardoc/HAML_REFERENCE.md.html)
252
253
4eeaac4 @rtomayko add basic liquid docs
authored
254 <a name='liquid'></a>
255 Liquid (`liquid`)
256 -----------------
257
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
258 [Liquid][liquid] is for rendering safe templates which cannot affect the
259 security of the server they are rendered on.
4eeaac4 @rtomayko add basic liquid docs
authored
260
261 ### Example
262
263 <html>
264 <head>
265 <title>{{ title }}</title>
266 </head>
267 <body>
268 <h1>Hello {{ world }}!</h1>
269 </body>
270 </html>
271
272 ### Usage
273
274 `Tilt::LiquidTemplate` is registered for all files ending in `.liquid` by
275 default. Liquid templates support locals and objects that respond to
276 `#to_h` as scopes:
277
278 >> require 'liquid'
279 >> require 'tilt'
280 >> template = Tilt.new('hello.liquid')
281 => #<Tilt::LiquidTemplate @file='hello.liquid'>
282 >> scope = { :title => "Hello Liquid Templates" }
283 >> template.render(nil, :world => "Liquid")
284 => "
285 <html>
286 <head>
287 <title>Hello Liquid Templates</title>
288 </head>
289 <body>
290 <h1>Hello Liquid!</h1>
291 </body>
292 </html>"
293
294 Or, use `Tilt::LiquidTemplate` directly to process strings:
295
296 >> require 'haml'
b52ddae @judofyr Add documentation for fallback mode
judofyr authored
297 >> template = Tilt::LiquidTemplate.new { "<h1>Hello Liquid!</h1>" }
4eeaac4 @rtomayko add basic liquid docs
authored
298 => #<Tilt::LiquidTemplate @file=nil ...>
299 >> template.render
300 => "<h1>Hello Liquid!</h1>"
301
302 __NOTE:__ It's suggested that your program `require 'liquid'` at load
303 time when using this template engine within a threaded environment.
304
305 ### See also
306
307 * [Liquid for Programmers](http://wiki.github.com/tobi/liquid/liquid-for-programmers)
308 * [Liquid Docs](http://liquid.rubyforge.org/)
309 * GitHub: [tobi/liquid](http://github.com/tobi/liquid/)
310
6f180e3 @rtomayko added markdown doc to TEMPLATES
authored
311
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
312 <a name='radius'></a>
313 Radius (`radius`)
314 -----------------
6f180e3 @rtomayko added markdown doc to TEMPLATES
authored
315
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
316 [Radius][radius] is the template language used by [Radiant CMS][radiant]. It is
317 a tag language designed to be valid XML/HTML.
6f180e3 @rtomayko added markdown doc to TEMPLATES
authored
318
319 ### Example
320
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
321 <html>
322 <body>
323 <h1><r:title /></h1>
324 <ul class="<r:type />">
325 <r:repeat times="3">
326 <li><r:hello />!</li>
327 </r:repeat>
328 </ul>
329 <r:yield />
330 </body>
331 </html>
23a141b @rtomayko RDocTemplate specs and docs
authored
332
333 ### Usage
334
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
335 To render a template such as the one above.
6f180e3 @rtomayko added markdown doc to TEMPLATES
authored
336
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
337 scope = OpenStruct.new
338 scope.title = "Radius Example"
339 scope.hello = "Hello, World!"
6f180e3 @rtomayko added markdown doc to TEMPLATES
authored
340
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
341 require 'radius'
342 template = Tilt::RadiusTemplate.new('example.radius', :tag_prefix=>'r')
343 template.render(scope, :type=>'hlist'){ "Jackpot!" }
23a141b @rtomayko RDocTemplate specs and docs
authored
344
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
345 The result will be:
346
347 <html>
348 <body>
349 <h1>Radius Example</h1>
350 <ul class="hlist">
351 <li>Hello, World!</li>
352 <li>Hello, World!</li>
353 <li>Hello, World!</li>
354 </ul>
355 Jackpot!
356 </body>
357 </html>
2f2aa38 @rtomayko :smart and :filter_html options for RDiscountTemplate
authored
358
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
359 ### See also
2f2aa38 @rtomayko :smart and :filter_html options for RDiscountTemplate
authored
360
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
361 * [Radius][radius]
362 * [Radiant CMS][radiant]
2f2aa38 @rtomayko :smart and :filter_html options for RDiscountTemplate
authored
363
364
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
365 <a name='textile'></a>
366 Textile (`textile`)
367 -------------------
2f2aa38 @rtomayko :smart and :filter_html options for RDiscountTemplate
authored
368
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
369 Textile is a lightweight markup language originally developed by Dean Allen and
370 billed as a "humane Web text generator". Textile converts its marked-up text
371 input to valid, well-formed XHTML and also inserts character entity references
372 for apostrophes, opening and closing single and double quotation marks,
373 ellipses and em dashes.
6f180e3 @rtomayko added markdown doc to TEMPLATES
authored
374
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
375 Textile formatted texts are converted to HTML with the [RedCloth][redcloth]
376 engine, which is a Ruby extension written in C.
6f180e3 @rtomayko added markdown doc to TEMPLATES
authored
377
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
378 ### Example
6f180e3 @rtomayko added markdown doc to TEMPLATES
authored
379
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
380 h1. Hello Textile Templates
381
382 Hello World. This is a paragraph.
383
384 ### Usage
385
386 __NOTE:__ It's suggested that your program `require 'redcloth'` at load time
387 when using this template engine in a threaded environment.
388
389 ### See Also
390
391 * [RedCloth][redcloth]
23a141b @rtomayko RDocTemplate specs and docs
authored
392
393
394 <a name='rdoc'></a>
395 RDoc (`rdoc`)
396 -------------
397
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
398 [RDoc][rdoc] is the simple text markup system that comes with Ruby's standard
23a141b @rtomayko RDocTemplate specs and docs
authored
399 library.
400
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
401 ### Example
402
403 = Hello RDoc Templates
404
405 Hello World. This is a paragraph.
406
23a141b @rtomayko RDocTemplate specs and docs
authored
407 ### Usage
408
409 __NOTE:__ It's suggested that your program `require 'rdoc/markup'` and
410 `require 'rdoc/markup/to_html'` at load time when using this template
411 engine in a threaded environment.
412
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
413 ### See also
23a141b @rtomayko RDocTemplate specs and docs
authored
414
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
415 * [RDoc][rdoc]
23a141b @rtomayko RDocTemplate specs and docs
authored
416
417
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
418 <a name='markdown'></a>
419 Markdown (`markdown`, `md`, `mkd`)
420 ----------------------------------
23a141b @rtomayko RDocTemplate specs and docs
authored
421
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
422 [Markdown][markdown] is a lightweight markup language, created by John Gruber
423 and Aaron Swartz. For any markup that is not covered by Markdown’s syntax, HTML
424 is used. Marking up plain text with Markdown markup is easy and Markdown
425 formatted texts are readable.
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
426
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
427 Markdown formatted texts are converted to HTML with one of these libraries:
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
428
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
429 * [RDiscount](#rdiscount) - `Tilt::RDiscountTemplate`
430 * BlueCloth - `Tilt::BlueClothTemplate`
431 * Kramdown - `Tilt::KramdownTemplate`
432 * Maruku - `Tilt::MarukuTemplate`
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
433
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
434 Tilt will use fallback mode (as documented in the README) for determining which
435 library to use. RDiscount has highest priority - Maruku has lowest.
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
436
437 ### Example
438
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
439 Hello Markdown Templates
440 ========================
441
442 Hello World. This is a paragraph.
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
443
444 ### Usage
445
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
446 To wrap a Markdown formatted document with a layout:
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
447
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
448 layout = Tilt['erb'].new do
449 "<!doctype html><title></title><%= yield %>"
450 end
451 data = Tilt['md'].new { "# hello tilt" }
452 layout.render { data.render }
453 # => "<!doctype html><title></title><h1>hello tilt</h1>\n"
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
454
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
455 ### Options
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
456
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
457 Every implementation of Markdown *should* support these options, but there are
458 some known problems with the Kramdown and Maruku engines.
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
459
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
460 #### `:smartypants => true|false`
461
462 Set `true` to enable [Smarty Pants][smartypants]
463 style punctuation replacement.
464
465 #### `:escape_html => true|false`
466
467 Set `true` disallow raw HTML in Markdown contents. HTML is converted to
468 literal text by escaping `<` characters.
469
470 ### See also
471
472 * [Markdown Syntax Documentation](http://daringfireball.net/projects/markdown/syntax/)
473
474 <a name='rdiscount'></a>
475 RDiscount (`markdown`, `md`, `mkd`)
476 -----------------------------------
477
478 [Discount][discount] is an implementation of the Markdown markup language in C.
479 [RDiscount][rdiscount] is a Ruby wrapper around Discount.
480
481 All the documentation of [Markdown](#markdown) applies in addition to the following:
482
483 ### Usage
484
485 The `Tilt::RDiscountTemplate` class is registered for all files ending in
486 `.markdown`, `.md` or `.mkd` by default with the highest priority. If you
487 specifically want to use RDiscount, it's recommended to use `#prefer`:
488
489 Tilt.prefer Tilt::RDiscountTemplate
490
491 __NOTE:__ It's suggested that your program `require 'erubis'` at load time when
492 using this template engine within a threaded environment.
c43c8d1 @trans add documentation for Radius and improve implementation
trans authored
493
494 ### See also
495
42ea5cb @judofyr Clean up TEMPLATES.md (#69, #74)
judofyr authored
496 * [Discount][discount]
497 * [RDiscount][rdiscount]
498 * GitHub: [rtomayko/rdiscount][rdiscount]
499
500
501 [lesscss]: http://lesscss.org/ "Less CSS"
502 [sass]: http://sass-lang.com/ "Sass"
503 [coffee-script]: http://jashkenas.github.com/coffee-script/ "Coffee Script"
504 [erubis]: http://www.kuwata-lab.com/erubis/ "Erubis"
505 [haml]: http://haml-lang.org/ "Haml"
506 [liquid]: http://www.liquidmarkup.org/ "Liquid"
507 [radius]: http://radius.rubyforge.org/ "Radius"
508 [radiant]: http://radiantcms.org/ "Radiant CMS"
509 [redcloth]: http://redcloth.org/ "RedCloth"
510 [rdoc]: http://rdoc.rubyforge.org/ "RDoc"
511 [discount]: http://www.pell.portland.or.us/~orc/Code/discount/ "Discount"
512 [rdiscount]: http://github.com/rtomayko/rdiscount/ "RDiscount"
513 [smartypants]: http://daringfireball.net/projects/smartypants/ "Smarty Pants"
514
Something went wrong with that request. Please try again.