tilt 1.4.1 → 2.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/COPYING +1 -1
- data/bin/tilt +18 -8
- data/lib/tilt/asciidoc.rb +1 -8
- data/lib/tilt/babel.rb +16 -0
- data/lib/tilt/bluecloth.rb +24 -0
- data/lib/tilt/builder.rb +12 -15
- data/lib/tilt/coffee.rb +10 -6
- data/lib/tilt/commonmarker.rb +88 -0
- data/lib/tilt/creole.rb +25 -0
- data/lib/tilt/csv.rb +12 -18
- data/lib/tilt/dummy.rb +3 -0
- data/lib/tilt/erb.rb +9 -56
- data/lib/tilt/erubi.rb +32 -0
- data/lib/tilt/erubis.rb +43 -0
- data/lib/tilt/haml.rb +66 -44
- data/lib/tilt/kramdown.rb +25 -0
- data/lib/tilt/less.rb +30 -0
- data/lib/tilt/liquid.rb +9 -10
- data/lib/tilt/livescript.rb +23 -0
- data/lib/tilt/mapping.rb +293 -0
- data/lib/tilt/markaby.rb +1 -8
- data/lib/tilt/maruku.rb +22 -0
- data/lib/tilt/nokogiri.rb +1 -8
- data/lib/tilt/pandoc.rb +57 -0
- data/lib/tilt/plain.rb +0 -4
- data/lib/tilt/prawn.rb +43 -0
- data/lib/tilt/radius.rb +1 -8
- data/lib/tilt/rdiscount.rb +39 -0
- data/lib/tilt/rdoc.rb +3 -10
- data/lib/tilt/redcarpet.rb +86 -0
- data/lib/tilt/{textile.rb → redcloth.rb} +1 -8
- data/lib/tilt/rst-pandoc.rb +23 -0
- data/lib/tilt/sass.rb +78 -0
- data/lib/tilt/sigil.rb +34 -0
- data/lib/tilt/string.rb +1 -1
- data/lib/tilt/template.rb +121 -105
- data/lib/tilt/typescript.rb +26 -0
- data/lib/tilt/wikicloth.rb +22 -0
- data/lib/tilt/yajl.rb +1 -8
- data/lib/tilt.rb +118 -155
- metadata +38 -469
- data/CHANGELOG.md +0 -44
- data/Gemfile +0 -32
- data/HACKING +0 -16
- data/README.md +0 -232
- data/Rakefile +0 -104
- data/TEMPLATES.md +0 -516
- data/lib/tilt/css.rb +0 -80
- data/lib/tilt/markdown.rb +0 -214
- data/lib/tilt/wiki.rb +0 -58
- data/test/contest.rb +0 -68
- data/test/markaby/locals.mab +0 -1
- data/test/markaby/markaby.mab +0 -1
- data/test/markaby/markaby_other_static.mab +0 -1
- data/test/markaby/render_twice.mab +0 -1
- data/test/markaby/scope.mab +0 -1
- data/test/markaby/yielding.mab +0 -2
- data/test/tilt_asciidoctor_test.rb +0 -44
- data/test/tilt_blueclothtemplate_test.rb +0 -45
- data/test/tilt_buildertemplate_test.rb +0 -59
- data/test/tilt_cache_test.rb +0 -32
- data/test/tilt_coffeescripttemplate_test.rb +0 -114
- data/test/tilt_compilesite_test.rb +0 -51
- data/test/tilt_creoletemplate_test.rb +0 -28
- data/test/tilt_csv_test.rb +0 -69
- data/test/tilt_erbtemplate_test.rb +0 -239
- data/test/tilt_erubistemplate_test.rb +0 -151
- data/test/tilt_etannitemplate_test.rb +0 -173
- data/test/tilt_fallback_test.rb +0 -122
- data/test/tilt_hamltemplate_test.rb +0 -144
- data/test/tilt_kramdown_test.rb +0 -42
- data/test/tilt_lesstemplate_test.less +0 -1
- data/test/tilt_lesstemplate_test.rb +0 -42
- data/test/tilt_liquidtemplate_test.rb +0 -78
- data/test/tilt_markaby_test.rb +0 -88
- data/test/tilt_markdown_test.rb +0 -172
- data/test/tilt_marukutemplate_test.rb +0 -48
- data/test/tilt_nokogiritemplate_test.rb +0 -87
- data/test/tilt_radiustemplate_test.rb +0 -75
- data/test/tilt_rdiscounttemplate_test.rb +0 -55
- data/test/tilt_rdoctemplate_test.rb +0 -31
- data/test/tilt_redcarpettemplate_test.rb +0 -71
- data/test/tilt_redclothtemplate_test.rb +0 -36
- data/test/tilt_sasstemplate_test.rb +0 -41
- data/test/tilt_stringtemplate_test.rb +0 -170
- data/test/tilt_template_test.rb +0 -323
- data/test/tilt_test.rb +0 -65
- data/test/tilt_wikiclothtemplate_test.rb +0 -32
- data/test/tilt_yajltemplate_test.rb +0 -101
- data/tilt.gemspec +0 -120
data/TEMPLATES.md
DELETED
@@ -1,516 +0,0 @@
|
|
1
|
-
Tilt Templates
|
2
|
-
==============
|
3
|
-
|
4
|
-
(See <https://github.com/rtomayko/tilt/blob/master/TEMPLATES.md> for a rendered,
|
5
|
-
HTML-version of this file).
|
6
|
-
|
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
|
-
|
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`
|
19
|
-
* [Erubis](#erubis) - `Tilt::ErubisTemplate`
|
20
|
-
* [Haml](#haml) - `Tilt::HamlTemplate`
|
21
|
-
* [Liquid](#liquid) - `Tilt::LiquidTemplate`
|
22
|
-
* Nokogiri - `Tilt::NokogiriTemplate`
|
23
|
-
* Builder - `Tilt::BuilderTemplate`
|
24
|
-
* Markaby - `Tilt::MarkabyTemplate`
|
25
|
-
* [Radius](#radius) - `Tilt::RadiusTemplate`
|
26
|
-
|
27
|
-
Tilt also includes support for CSS processors like [LessCSS][lesscss] and
|
28
|
-
[Sass][sass], [CoffeeScript][coffee-script] and some simple text formats.
|
29
|
-
|
30
|
-
* Less - `Tilt::LessTemplate`
|
31
|
-
* Sass - `Tilt::SassTemplate`
|
32
|
-
* Scss - `Tilt::ScssTemplate`
|
33
|
-
* CoffeeScript - `Tilt::CoffeeScriptTemplate`
|
34
|
-
* [Textile](#redcloth) - `Tilt::RedClothTemplate`
|
35
|
-
* Creole - `Tilt::CreoleTemplate`
|
36
|
-
* [RDoc](#rdoc) - `Tilt::RDocTemplate`
|
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
|
-
|
48
|
-
<a name='erb'></a>
|
49
|
-
ERB (`erb`, `rhtml`)
|
50
|
-
--------------------
|
51
|
-
|
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.
|
56
|
-
|
57
|
-
### Example
|
58
|
-
|
59
|
-
Hello <%= world %>!
|
60
|
-
|
61
|
-
### Usage
|
62
|
-
|
63
|
-
ERB templates support custom evaluation scopes and locals:
|
64
|
-
|
65
|
-
>> require 'erb'
|
66
|
-
>> template = Tilt.new('hello.html.erb')
|
67
|
-
>> template.render(self, :world => 'World!')
|
68
|
-
=> "Hello World!"
|
69
|
-
|
70
|
-
Or, use `Tilt['erb']` directly to process strings:
|
71
|
-
|
72
|
-
template = Tilt['erb'].new { "Hello <%= world %>!" }
|
73
|
-
template.render(self, :world => 'World!')
|
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
|
-
|
107
|
-
__NOTE:__ It's suggested that your program `require 'erb'` at load time when
|
108
|
-
using this template engine within a threaded environment.
|
109
|
-
|
110
|
-
### Options
|
111
|
-
|
112
|
-
#### `:trim => true`
|
113
|
-
|
114
|
-
The ERB trim mode flags. This is a string consisting of any combination of the
|
115
|
-
following characters:
|
116
|
-
|
117
|
-
* `'>'` omits newlines for lines ending in `>`
|
118
|
-
* `'<>'` omits newlines for lines starting with `<%` and ending in `%>`
|
119
|
-
* `'%'` enables processing of lines beginning with `%`
|
120
|
-
* `true` is an alias of `<>`
|
121
|
-
|
122
|
-
#### `:safe => nil`
|
123
|
-
|
124
|
-
The `$SAFE` level; when set, ERB code will be run in a
|
125
|
-
separate thread with `$SAFE` set to the provided level.
|
126
|
-
|
127
|
-
#### `:outvar => '_erbout'`
|
128
|
-
|
129
|
-
The name of the variable used to accumulate template output. This can be
|
130
|
-
any valid Ruby expression but must be assignable. By default a local
|
131
|
-
variable named `_erbout` is used.
|
132
|
-
|
133
|
-
### See also
|
134
|
-
|
135
|
-
* [ERB documentation](http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html)
|
136
|
-
|
137
|
-
|
138
|
-
<a name='erubis'></a>
|
139
|
-
Erubis (`erb`, `rhtml`, `erubis`)
|
140
|
-
---------------------------------
|
141
|
-
|
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:
|
145
|
-
|
146
|
-
### Usage
|
147
|
-
|
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
|
153
|
-
|
154
|
-
__NOTE:__ It's suggested that your program `require 'erubis'` at load time when
|
155
|
-
using this template engine within a threaded environment.
|
156
|
-
|
157
|
-
### Options
|
158
|
-
|
159
|
-
#### `:engine_class => Erubis::Eruby`
|
160
|
-
|
161
|
-
Allows you to specify a custom engine class to use instead of the
|
162
|
-
default which is `Erubis::Eruby`.
|
163
|
-
|
164
|
-
#### `:escape_html => false`
|
165
|
-
|
166
|
-
When `true`, `Erubis::EscapedEruby` will be used as the engine class
|
167
|
-
instead of the default. All content within `<%= %>` blocks will be
|
168
|
-
automatically html escaped.
|
169
|
-
|
170
|
-
#### `:outvar => '_erbout'`
|
171
|
-
|
172
|
-
The name of the variable used to accumulate template output. This can be
|
173
|
-
any valid Ruby expression but must be assignable. By default a local
|
174
|
-
variable named `_erbout` is used.
|
175
|
-
|
176
|
-
#### `:pattern => '<% %>'`
|
177
|
-
|
178
|
-
Set pattern for embedded Ruby code.
|
179
|
-
|
180
|
-
#### `:trim => true`
|
181
|
-
|
182
|
-
Delete spaces around `<% %>`. (But, spaces around `<%= %>` are preserved.)
|
183
|
-
|
184
|
-
### See also
|
185
|
-
|
186
|
-
* [Erubis Home][erubis]
|
187
|
-
* [Erubis User's Guide](http://www.kuwata-lab.com/erubis/users-guide.html)
|
188
|
-
|
189
|
-
|
190
|
-
<a name='haml'></a>
|
191
|
-
Haml (`haml`)
|
192
|
-
-------------
|
193
|
-
|
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.
|
200
|
-
([more](http://haml.info/about.html))
|
201
|
-
|
202
|
-
|
203
|
-
### Example
|
204
|
-
|
205
|
-
%html
|
206
|
-
%head
|
207
|
-
%title= @title
|
208
|
-
%body
|
209
|
-
%h1
|
210
|
-
Hello
|
211
|
-
= world + '!'
|
212
|
-
|
213
|
-
### Usage
|
214
|
-
|
215
|
-
The `Tilt::HamlTemplate` class is registered for all files ending in `.haml`
|
216
|
-
by default. Haml templates support custom evaluation scopes and locals:
|
217
|
-
|
218
|
-
>> require 'haml'
|
219
|
-
>> template = Tilt.new('hello.haml')
|
220
|
-
=> #<Tilt::HamlTemplate @file='hello.haml'>
|
221
|
-
>> @title = "Hello Haml!"
|
222
|
-
>> template.render(self, :world => 'Haml!')
|
223
|
-
=> "
|
224
|
-
<html>
|
225
|
-
<head>
|
226
|
-
<title>Hello Haml!</title>
|
227
|
-
</head>
|
228
|
-
<body>
|
229
|
-
<h1>Hello Haml!</h1>
|
230
|
-
</body>
|
231
|
-
</html>"
|
232
|
-
|
233
|
-
Or, use the `Tilt::HamlTemplate` class directly to process strings:
|
234
|
-
|
235
|
-
>> require 'haml'
|
236
|
-
>> template = Tilt::HamlTemplate.new { "%h1= 'Hello Haml!'" }
|
237
|
-
=> #<Tilt::HamlTemplate @file=nil ...>
|
238
|
-
>> template.render
|
239
|
-
=> "<h1>Hello Haml!</h1>"
|
240
|
-
|
241
|
-
__NOTE:__ It's suggested that your program `require 'haml'` at load time when
|
242
|
-
using this template engine within a threaded environment.
|
243
|
-
|
244
|
-
### Options
|
245
|
-
|
246
|
-
Please see the [Haml Reference](http://haml.info/docs/yardoc/file.HAML_REFERENCE.html#options) for all available options.
|
247
|
-
|
248
|
-
### See also
|
249
|
-
|
250
|
-
* [#haml.docs](http://haml.info/docs.html)
|
251
|
-
* [Haml Tutorial](http://haml.info/tutorial.html)
|
252
|
-
* [Haml Reference](http://haml.info/docs/yardoc/file.HAML_REFERENCE.html)
|
253
|
-
|
254
|
-
|
255
|
-
<a name='liquid'></a>
|
256
|
-
Liquid (`liquid`)
|
257
|
-
-----------------
|
258
|
-
|
259
|
-
[Liquid][liquid] is for rendering safe templates which cannot affect the
|
260
|
-
security of the server they are rendered on.
|
261
|
-
|
262
|
-
### Example
|
263
|
-
|
264
|
-
<html>
|
265
|
-
<head>
|
266
|
-
<title>{{ title }}</title>
|
267
|
-
</head>
|
268
|
-
<body>
|
269
|
-
<h1>Hello {{ world }}!</h1>
|
270
|
-
</body>
|
271
|
-
</html>
|
272
|
-
|
273
|
-
### Usage
|
274
|
-
|
275
|
-
`Tilt::LiquidTemplate` is registered for all files ending in `.liquid` by
|
276
|
-
default. Liquid templates support locals and objects that respond to
|
277
|
-
`#to_h` as scopes:
|
278
|
-
|
279
|
-
>> require 'liquid'
|
280
|
-
>> require 'tilt'
|
281
|
-
>> template = Tilt.new('hello.liquid')
|
282
|
-
=> #<Tilt::LiquidTemplate @file='hello.liquid'>
|
283
|
-
>> scope = { :title => "Hello Liquid Templates" }
|
284
|
-
>> template.render(nil, :world => "Liquid")
|
285
|
-
=> "
|
286
|
-
<html>
|
287
|
-
<head>
|
288
|
-
<title>Hello Liquid Templates</title>
|
289
|
-
</head>
|
290
|
-
<body>
|
291
|
-
<h1>Hello Liquid!</h1>
|
292
|
-
</body>
|
293
|
-
</html>"
|
294
|
-
|
295
|
-
Or, use `Tilt::LiquidTemplate` directly to process strings:
|
296
|
-
|
297
|
-
>> require 'liquid'
|
298
|
-
>> template = Tilt::LiquidTemplate.new { "<h1>Hello Liquid!</h1>" }
|
299
|
-
=> #<Tilt::LiquidTemplate @file=nil ...>
|
300
|
-
>> template.render
|
301
|
-
=> "<h1>Hello Liquid!</h1>"
|
302
|
-
|
303
|
-
__NOTE:__ It's suggested that your program `require 'liquid'` at load
|
304
|
-
time when using this template engine within a threaded environment.
|
305
|
-
|
306
|
-
### See also
|
307
|
-
|
308
|
-
* [Liquid for Programmers](https://wiki.github.com/Shopify/liquid/liquid-for-programmers)
|
309
|
-
* [Liquid Docs](http://liquid.rubyforge.org/)
|
310
|
-
* GitHub: [Shopify/liquid](https://github.com/Shopify/liquid/)
|
311
|
-
|
312
|
-
|
313
|
-
<a name='radius'></a>
|
314
|
-
Radius (`radius`)
|
315
|
-
-----------------
|
316
|
-
|
317
|
-
[Radius][radius] is the template language used by [Radiant CMS][radiant]. It is
|
318
|
-
a tag language designed to be valid XML/HTML.
|
319
|
-
|
320
|
-
### Example
|
321
|
-
|
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>
|
333
|
-
|
334
|
-
### Usage
|
335
|
-
|
336
|
-
To render a template such as the one above.
|
337
|
-
|
338
|
-
scope = OpenStruct.new
|
339
|
-
scope.title = "Radius Example"
|
340
|
-
scope.hello = "Hello, World!"
|
341
|
-
|
342
|
-
require 'radius'
|
343
|
-
template = Tilt::RadiusTemplate.new('example.radius', :tag_prefix=>'r')
|
344
|
-
template.render(scope, :type=>'hlist'){ "Jackpot!" }
|
345
|
-
|
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>
|
359
|
-
|
360
|
-
### See also
|
361
|
-
|
362
|
-
* [Radius][radius]
|
363
|
-
* [Radiant CMS][radiant]
|
364
|
-
|
365
|
-
|
366
|
-
<a name='textile'></a>
|
367
|
-
Textile (`textile`)
|
368
|
-
-------------------
|
369
|
-
|
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.
|
375
|
-
|
376
|
-
Textile formatted texts are converted to HTML with the [RedCloth][redcloth]
|
377
|
-
engine, which is a Ruby extension written in C.
|
378
|
-
|
379
|
-
### Example
|
380
|
-
|
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]
|
393
|
-
|
394
|
-
|
395
|
-
<a name='rdoc'></a>
|
396
|
-
RDoc (`rdoc`)
|
397
|
-
-------------
|
398
|
-
|
399
|
-
[RDoc][rdoc] is the simple text markup system that comes with Ruby's standard
|
400
|
-
library.
|
401
|
-
|
402
|
-
### Example
|
403
|
-
|
404
|
-
= Hello RDoc Templates
|
405
|
-
|
406
|
-
Hello World. This is a paragraph.
|
407
|
-
|
408
|
-
### Usage
|
409
|
-
|
410
|
-
__NOTE:__ It's suggested that your program `require 'rdoc'`,
|
411
|
-
`require 'rdoc/markup'`, and `require 'rdoc/markup/to_html'` at load time
|
412
|
-
when using this template engine in a threaded environment.
|
413
|
-
|
414
|
-
### See also
|
415
|
-
|
416
|
-
* [RDoc][rdoc]
|
417
|
-
|
418
|
-
|
419
|
-
<a name='markdown'></a>
|
420
|
-
Markdown (`markdown`, `md`, `mkd`)
|
421
|
-
----------------------------------
|
422
|
-
|
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.
|
427
|
-
|
428
|
-
Markdown formatted texts are converted to HTML with one of these libraries:
|
429
|
-
|
430
|
-
* [RDiscount](#rdiscount) - `Tilt::RDiscountTemplate`
|
431
|
-
* Redcarpet - `Tilt::RedcarpetTemplate`
|
432
|
-
* BlueCloth - `Tilt::BlueClothTemplate`
|
433
|
-
* Kramdown - `Tilt::KramdownTemplate`
|
434
|
-
* Maruku - `Tilt::MarukuTemplate`
|
435
|
-
|
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.
|
438
|
-
|
439
|
-
### Example
|
440
|
-
|
441
|
-
Hello Markdown Templates
|
442
|
-
========================
|
443
|
-
|
444
|
-
Hello World. This is a paragraph.
|
445
|
-
|
446
|
-
### Usage
|
447
|
-
|
448
|
-
To wrap a Markdown formatted document with a layout:
|
449
|
-
|
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"
|
456
|
-
|
457
|
-
### Options
|
458
|
-
|
459
|
-
Every implementation of Markdown *should* support these options, but there are
|
460
|
-
some known problems with the Kramdown and Maruku engines.
|
461
|
-
|
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.
|
471
|
-
|
472
|
-
### See also
|
473
|
-
|
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.info/ "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
|
-
|
data/lib/tilt/css.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'tilt/template'
|
2
|
-
|
3
|
-
module Tilt
|
4
|
-
# Sass template implementation. See:
|
5
|
-
# http://haml.hamptoncatlin.com/
|
6
|
-
#
|
7
|
-
# Sass templates do not support object scopes, locals, or yield.
|
8
|
-
class SassTemplate < Template
|
9
|
-
self.default_mime_type = 'text/css'
|
10
|
-
|
11
|
-
def self.engine_initialized?
|
12
|
-
defined? ::Sass::Engine
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize_engine
|
16
|
-
require_template_library 'sass'
|
17
|
-
end
|
18
|
-
|
19
|
-
def prepare
|
20
|
-
@engine = ::Sass::Engine.new(data, sass_options)
|
21
|
-
end
|
22
|
-
|
23
|
-
def evaluate(scope, locals, &block)
|
24
|
-
@output ||= @engine.render
|
25
|
-
end
|
26
|
-
|
27
|
-
def allows_script?
|
28
|
-
false
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
def sass_options
|
33
|
-
options.merge(:filename => eval_file, :line => line, :syntax => :sass)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# Sass's new .scss type template implementation.
|
38
|
-
class ScssTemplate < SassTemplate
|
39
|
-
self.default_mime_type = 'text/css'
|
40
|
-
|
41
|
-
private
|
42
|
-
def sass_options
|
43
|
-
options.merge(:filename => eval_file, :line => line, :syntax => :scss)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Lessscss template implementation. See:
|
48
|
-
# http://lesscss.org/
|
49
|
-
#
|
50
|
-
# Less templates do not support object scopes, locals, or yield.
|
51
|
-
class LessTemplate < Template
|
52
|
-
self.default_mime_type = 'text/css'
|
53
|
-
|
54
|
-
def self.engine_initialized?
|
55
|
-
defined? ::Less
|
56
|
-
end
|
57
|
-
|
58
|
-
def initialize_engine
|
59
|
-
require_template_library 'less'
|
60
|
-
end
|
61
|
-
|
62
|
-
def prepare
|
63
|
-
if ::Less.const_defined? :Engine
|
64
|
-
@engine = ::Less::Engine.new(data)
|
65
|
-
else
|
66
|
-
parser = ::Less::Parser.new(options.merge :filename => eval_file, :line => line)
|
67
|
-
@engine = parser.parse(data)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def evaluate(scope, locals, &block)
|
72
|
-
@output ||= @engine.to_css(options)
|
73
|
-
end
|
74
|
-
|
75
|
-
def allows_script?
|
76
|
-
false
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|