slim 2.0.3 → 2.1.0

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -8
  3. data/.yardopts +1 -1
  4. data/CHANGES +23 -0
  5. data/Gemfile +2 -1
  6. data/LICENSE +1 -1
  7. data/README.jp.md +497 -268
  8. data/README.md +505 -278
  9. data/Rakefile +14 -2
  10. data/benchmarks/view.haml +2 -2
  11. data/doc/include.md +20 -0
  12. data/doc/jp/include.md +20 -0
  13. data/doc/jp/logic_less.md +137 -0
  14. data/doc/jp/smart.md +102 -0
  15. data/doc/jp/translator.md +28 -0
  16. data/doc/smart.md +102 -0
  17. data/lib/slim/command.rb +8 -2
  18. data/lib/slim/controls.rb +4 -3
  19. data/lib/slim/do_inserter.rb +1 -1
  20. data/lib/slim/embedded.rb +26 -22
  21. data/lib/slim/end_inserter.rb +1 -1
  22. data/lib/slim/engine.rb +3 -2
  23. data/lib/slim/filter.rb +2 -2
  24. data/lib/slim/grammar.rb +3 -1
  25. data/lib/slim/include.rb +54 -0
  26. data/lib/slim/interpolation.rb +1 -1
  27. data/lib/slim/parser.rb +61 -46
  28. data/lib/slim/smart.rb +8 -0
  29. data/lib/slim/smart/escaper.rb +42 -0
  30. data/lib/slim/smart/filter.rb +96 -0
  31. data/lib/slim/smart/parser.rb +33 -0
  32. data/lib/slim/splat/builder.rb +3 -3
  33. data/lib/slim/splat/filter.rb +2 -2
  34. data/lib/slim/translator.rb +2 -2
  35. data/lib/slim/version.rb +1 -1
  36. data/slim.gemspec +1 -1
  37. data/test/core/helper.rb +5 -3
  38. data/test/core/test_code_blocks.rb +11 -0
  39. data/test/core/test_code_escaping.rb +14 -4
  40. data/test/core/test_embedded_engines.rb +26 -0
  41. data/test/core/test_html_structure.rb +39 -0
  42. data/test/core/test_parser_errors.rb +8 -25
  43. data/test/core/test_pretty.rb +15 -0
  44. data/test/core/test_ruby_errors.rb +0 -10
  45. data/test/include/files/recursive.slim +1 -0
  46. data/test/include/files/slimfile.slim +3 -0
  47. data/test/include/files/subdir/test.slim +1 -0
  48. data/test/include/files/textfile +1 -0
  49. data/test/include/test_include.rb +23 -0
  50. data/test/literate/TESTS.md +17 -2
  51. data/test/rails/test/test_slim.rb +1 -1
  52. data/test/smart/test_smart_text.rb +300 -0
  53. data/test/translator/test_translator.rb +7 -6
  54. metadata +22 -4
data/README.md CHANGED
@@ -14,9 +14,11 @@ A short list of the features...
14
14
  * Safety
15
15
  * Automatic HTML escaping by default
16
16
  * Support for Rails' `html_safe?`
17
- * Highly configurable and extendable via plugins
18
- * Logic less mode similar to Mustache, realized as plugin
19
- * Translator/I18n, realized as plugin
17
+ * Highly configurable
18
+ * Extensible via the following plugins:
19
+ * Logic less mode similar to Mustache
20
+ * Includes
21
+ * Translator/I18n
20
22
  * High performance
21
23
  * Comparable speed to ERB/Erubis
22
24
  * Streaming support in Rails
@@ -26,6 +28,7 @@ A short list of the features...
26
28
 
27
29
  ## Links
28
30
 
31
+ * Homepage: <http://slim-lang.com>
29
32
  * Source: <http://github.com/slim-template/slim>
30
33
  * Bugs: <http://github.com/slim-template/slim/issues>
31
34
  * List: <http://groups.google.com/group/slim-template>
@@ -47,24 +50,27 @@ As more people have contributed to Slim, there have been syntax additions influe
47
50
  Slim uses [Temple](https://github.com/judofyr/temple) for parsing/compilation and is also integrated into [Tilt](https://github.com/rtomayko/tilt), so it can be used together with [Sinatra](https://github.com/sinatra/sinatra) or plain [Rack](https://github.com/rack/rack).
48
51
 
49
52
  The architecture of Temple is very flexible and allows the extension of the parsing and compilation process without monkey-patching. This is used
50
- by the logic less plugin and the translator plugin which provides I18n.
53
+ by the logic less plugin and the translator plugin which provides I18n. In logic-less mode you can use Slim if you like the Slim syntax to build your HTML but don't want to write Ruby in your templates.
51
54
 
52
55
  ### Why use Slim?
53
56
 
54
- Within the Rails community, _Erb_ and _Haml_ are without doubt the two most popular templating engines. However, _Erb_'s syntax is cumbersome and _Haml_'s syntax can be quite cryptic to the uninitiated.
57
+ * Slim allows you to write very minimal templates which are easy to maintain and pretty much guarantees that you write well-formed HTML and XML
58
+ * We also think that the Slim syntax is also aesthetic and makes it much more fun to write templates. Since you can use Slim as a drop-in replacement in all the major framework you can start easily.
59
+ * The Slim architecture is very flexible and allows you to write syntax extensions and plugins.
55
60
 
56
- There is also some development in logic-less engines (e.g. [Mustache](https://github.com/defunkt/mustache) which requires you to write standard HTML). You can also use Slim in logic-less mode if you like the Slim syntax to build your HTML but don't want to write Ruby in your templates.
57
-
58
- Slim was born to bring a minimalist syntax approach with speed. If people chose not to use Slim, it would not be because of speed.
59
-
60
- ___Yes, Slim is speedy!___ Benchmarks are done for every commit at <http://travis-ci.org/slim-template/slim>.
61
+ ___Yes, Slim is speedy!___ Slim was developed right from the start with performance in mind.
62
+ Benchmarks are done for every commit at <http://travis-ci.org/slim-template/slim>.
61
63
  Don't trust the numbers? That's as it should be. Please try the benchmark rake task yourself!
62
64
 
65
+ However in our opionion you should use Slim because of its features and syntax. We just ensure that Slim doesn't have a negative impact on the performance of your application.
66
+
63
67
  ### How to start?
64
68
 
65
69
  Install Slim as a gem:
66
70
 
67
- gem install slim
71
+ ~~~
72
+ gem install slim
73
+ ~~~
68
74
 
69
75
  Include Slim in your Gemfile with `gem 'slim'` or require it with `require 'slim'`. That's it! Now, just use the .slim extension and you're good to go.
70
76
 
@@ -72,107 +78,124 @@ Include Slim in your Gemfile with `gem 'slim'` or require it with `require 'slim
72
78
 
73
79
  Here's a quick example to demonstrate what a Slim template looks like:
74
80
 
75
- doctype html
76
- html
77
- head
78
- title Slim Examples
79
- meta name="keywords" content="template language"
80
- meta name="author" content=author
81
- link rel="icon" type="image/png" href=file_path("favicon.png")
82
- javascript:
83
- alert('Slim supports embedded javascript!')
84
-
85
- body
86
- h1 Markup examples
87
-
88
- #content
89
- p This example shows you how a basic Slim file looks.
90
-
91
- == yield
92
-
93
- - if items.any?
94
- table#items
95
- - for item in items
96
- tr
97
- td.name = item.name
98
- td.price = item.price
99
- - else
100
- p No items found Please add some inventory.
101
- Thank you!
102
-
103
- div id="footer"
104
- == render 'footer'
105
- | Copyright &copy; #{@year} #{@author}
81
+ ~~~ slim
82
+ doctype html
83
+ html
84
+ head
85
+ title Slim Examples
86
+ meta name="keywords" content="template language"
87
+ meta name="author" content=author
88
+ link rel="icon" type="image/png" href=file_path("favicon.png")
89
+ javascript:
90
+ alert('Slim supports embedded javascript!')
91
+
92
+ body
93
+ h1 Markup examples
94
+
95
+ #content
96
+ p This example shows you how a basic Slim file looks.
97
+
98
+ == yield
99
+
100
+ - if items.any?
101
+ table#items
102
+ - for item in items
103
+ tr
104
+ td.name = item.name
105
+ td.price = item.price
106
+ - else
107
+ p No items found. Please add some inventory.
108
+ Thank you!
109
+
110
+ div id="footer"
111
+ == render 'footer'
112
+ | Copyright &copy; #{@year} #{@author}
113
+ ~~~
106
114
 
107
115
  Indentation matters, but the indentation depth can be chosen as you like. If you want to first indent 2 spaces, then 5 spaces, it's your choice. To nest markup you only need to indent by one space, the rest is gravy.
108
116
 
109
117
  ## Line indicators
110
118
 
111
- ### Text `|`
119
+ ### Verbatim text `|`
112
120
 
113
121
  The pipe tells Slim to just copy the line. It essentially escapes any processing.
114
122
  Each following line that is indented greater than the pipe is copied over.
115
123
 
116
- body
117
- p
118
- |
119
- This is a test of the text block.
124
+ ~~~ slim
125
+ body
126
+ p
127
+ |
128
+ This is a test of the text block.
129
+ ~~~
120
130
 
121
131
  The parsed result of the above:
122
132
 
123
- <body><p>This is a test of the text block.</p></body>
133
+ ~~~ html
134
+ <body><p>This is a test of the text block.</p></body>
135
+ ~~~
124
136
 
125
- The left margin is set at the indent of the pipe + one space.
137
+ If the text starts on the same line, the left margin is set at the indent of the pipe + one space.
126
138
  Any additional spaces will be copied over.
127
139
 
128
- body
129
- p
130
- | This line is on the left margin.
131
- This line will have one space in front of it.
132
- This line will have two spaces in front of it.
133
- And so on...
140
+ ~~~ slim
141
+ body
142
+ p
143
+ | This line is on the left margin.
144
+ This line will have one space in front of it.
145
+ This line will have two spaces in front of it.
146
+ And so on...
147
+ ~~~
134
148
 
135
149
  You can also embed html in the text line
136
150
 
137
- - articles.each do |a|
138
- | <tr><td>#{a.name}</td><td>#{a.description}</td></tr>
151
+ ~~~ slim
152
+ - articles.each do |a|
153
+ | <tr><td>#{a.name}</td><td>#{a.description}</td></tr>
154
+ ~~~
139
155
 
140
- ### Text with trailing white space `'`
156
+ ### Verbatim text with trailing white space `'`
141
157
 
142
158
  The single quote tells Slim to copy the line (similar to `|`), but makes sure that a single trailing white space is appended.
143
159
 
144
- ### Inline html `<` (HTML style)
160
+ ### Inline html `<`
145
161
 
146
162
  You can write html tags directly in Slim which allows you to write your templates in a more html like style with closing tags or mix html and Slim style.
163
+ The leading `<` works like an implicit `|`:
147
164
 
148
- <html>
149
- head
150
- title Example
151
- <body>
152
- - if articles.empty?
153
- - else
154
- table
155
- - articles.each do |a|
156
- <tr><td>#{a.name}</td><td>#{a.description}</td></tr>
157
- </body>
158
- </html>
165
+ ~~~ slim
166
+ <html>
167
+ head
168
+ title Example
169
+ <body>
170
+ - if articles.empty?
171
+ - else
172
+ table
173
+ - articles.each do |a|
174
+ <tr><td>#{a.name}</td><td>#{a.description}</td></tr>
175
+ </body>
176
+ </html>
177
+ ~~~
159
178
 
160
179
  ### Control code `-`
161
180
 
162
181
  The dash denotes control code. Examples of control code are loops and conditionals. `end` is forbidden behind `-`. Blocks are defined only by indentation.
163
182
  If your ruby code needs to use multiple lines, append a backslash `\` at the end of the lines. If your line ends with comma `,` (e.g because of a method call) you don't need the additional backslash before the linebreak.
164
183
 
165
- body
166
- - if articles.empty?
167
- | No inventory
184
+ ~~~ slim
185
+ body
186
+ - if articles.empty?
187
+ | No inventory
188
+ ~~~
168
189
 
169
190
  ### Output `=`
170
191
 
171
192
  The equal sign tells Slim it's a Ruby call that produces output to add to the buffer. If your ruby code needs to use multiple lines, append a backslash `\` at the end of the lines, for example:
172
193
 
173
- = javascript_include_tag \
174
- "jquery",
175
- "application"
194
+ ~~~ slim
195
+ = javascript_include_tag \
196
+ "jquery",
197
+ "application"
198
+ ~~~
176
199
 
177
200
  If your line ends with comma `,` (e.g because of a method call) you don't need the additional backslash before the linebreak. For trailing or leading whitespace the modifiers `>` and `<` are supported.
178
201
 
@@ -190,15 +213,19 @@ Same as the single equal sign (`=`), but does not go through the `escape_html` m
190
213
 
191
214
  Use the forward slash for code comments - anything after it won't get displayed in the final render. Use `/` for code comments and `/!` for html comments
192
215
 
193
- body
194
- p
195
- / This line won't get displayed.
196
- Neither does this line.
197
- /! This will get displayed as html comments.
216
+ ~~~ slim
217
+ body
218
+ p
219
+ / This line won't get displayed.
220
+ Neither does this line.
221
+ /! This will get displayed as html comments.
222
+ ~~~
198
223
 
199
224
  The parsed result of the above:
200
225
 
201
- <body><p><!--This will get displayed as html comments.--></p></body>
226
+ ~~~ html
227
+ <body><p><!--This will get displayed as html comments.--></p></body>
228
+ ~~~
202
229
 
203
230
  ### HTML comment `/!`
204
231
 
@@ -206,12 +233,16 @@ Use the forward slash immediately followed by an exclamation mark for html comme
206
233
 
207
234
  ### IE conditional comment `/[...]`
208
235
 
209
- /[if IE]
210
- p Get a better browser.
236
+ ~~~ slim
237
+ /[if IE]
238
+ p Get a better browser.
239
+ ~~~
211
240
 
212
241
  renders as
213
242
 
214
- <!--[if IE]><p>Get a better browser.</p><![endif]-->
243
+ ~~~ html
244
+ <!--[if IE]><p>Get a better browser.</p><![endif]-->
245
+ ~~~
215
246
 
216
247
  ## HTML tags
217
248
 
@@ -221,128 +252,165 @@ The doctype tag is a special tag which can be used to generate the complex docty
221
252
 
222
253
  XML VERSION
223
254
 
224
- doctype xml
225
- <?xml version="1.0" encoding="utf-8" ?>
255
+ ~~~~ slim
256
+ doctype xml
257
+ <?xml version="1.0" encoding="utf-8" ?>
226
258
 
227
- doctype xml ISO-8859-1
228
- <?xml version="1.0" encoding="iso-8859-1" ?>
259
+ doctype xml ISO-8859-1
260
+ <?xml version="1.0" encoding="iso-8859-1" ?>
261
+ ~~~
229
262
 
230
263
  XHTML DOCTYPES
231
264
 
232
- doctype html
233
- <!DOCTYPE html>
265
+ ~~~ slim
266
+ doctype html
267
+ <!DOCTYPE html>
234
268
 
235
- doctype 5
236
- <!DOCTYPE html>
269
+ doctype 5
270
+ <!DOCTYPE html>
237
271
 
238
- doctype 1.1
239
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
240
- "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
272
+ doctype 1.1
273
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
274
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
241
275
 
242
- doctype strict
243
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
244
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
276
+ doctype strict
277
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
278
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
245
279
 
246
- doctype frameset
247
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
248
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
280
+ doctype frameset
281
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
282
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
249
283
 
250
- doctype mobile
251
- <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN"
252
- "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
284
+ doctype mobile
285
+ <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN"
286
+ "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
253
287
 
254
- doctype basic
255
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
256
- "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
288
+ doctype basic
289
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
290
+ "http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
257
291
 
258
- doctype transitional
259
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
260
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
292
+ doctype transitional
293
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
294
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
295
+ ~~~
261
296
 
262
297
  HTML 4 DOCTYPES
263
298
 
264
- doctype strict
265
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
266
- "http://www.w3.org/TR/html4/strict.dtd">
299
+ ~~~ slim
300
+ doctype strict
301
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
302
+ "http://www.w3.org/TR/html4/strict.dtd">
267
303
 
268
- doctype frameset
269
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
270
- "http://www.w3.org/TR/html4/frameset.dtd">
304
+ doctype frameset
305
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
306
+ "http://www.w3.org/TR/html4/frameset.dtd">
271
307
 
272
- doctype transitional
273
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
274
- "http://www.w3.org/TR/html4/loose.dtd">
308
+ doctype transitional
309
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
310
+ "http://www.w3.org/TR/html4/loose.dtd">
311
+ ~~~
275
312
 
276
313
  ### Closed tags (trailing `/`)
277
314
 
278
315
  You can close tags explicitly by appending a trailing `/`.
279
316
 
280
- img src="image.png"/
317
+ ~~~ slim
318
+ img src="image.png"/
319
+ ~~~
281
320
 
282
321
  Note, that this is usually not necessary since the standard html
283
322
  tags (img, br, ...) are closed automatically.
284
323
 
285
324
  ### Trailing and leading whitespace (`<`, `>`)
286
325
 
287
- You can force Slim to add a trailing whitespace after a tag by adding a >.
326
+ You can force Slim to add a trailing whitespace after a tag by adding a `>`.
288
327
 
289
- a> href='url1' Link1
290
- a> href='url2' Link2
328
+ ~~~ slim
329
+ a> href='url1' Link1
330
+ a> href='url2' Link2
331
+ ~~~
291
332
 
292
- You can add a leading whitespace by adding <.
333
+ You can add a leading whitespace by adding `<`.
293
334
 
294
- a< href='url1' Link1
295
- a< href='url2' Link2
335
+ ~~~ slim
336
+ a< href='url1' Link1
337
+ a< href='url2' Link2
338
+ ~~~
296
339
 
297
340
  You can also combine both.
298
341
 
299
- a<> href='url1' Link1
342
+ ~~~ slim
343
+ a<> href='url1' Link1
344
+ ~~~
300
345
 
301
346
  ### Inline tags
302
347
 
303
348
  Sometimes you may want to be a little more compact and inline the tags.
304
349
 
305
- ul
306
- li.first: a href="/a" A link
307
- li: a href="/b" B link
350
+ ~~~ slim
351
+ ul
352
+ li.first: a href="/a" A link
353
+ li: a href="/b" B link
354
+ ~~~
308
355
 
309
356
  For readability, don't forget you can wrap the attributes.
310
357
 
311
- ul
312
- li.first: a[href="/a"] A link
313
- li: a[href="/b"] B link
358
+ ~~~ slim
359
+ ul
360
+ li.first: a[href="/a"] A link
361
+ li: a[href="/b"] B link
362
+ ~~~
314
363
 
315
364
  ### Text content
316
365
 
317
366
  Either start on the same line as the tag
318
367
 
319
- body
320
- h1 id="headline" Welcome to my site.
368
+ ~~~ slim
369
+ body
370
+ h1 id="headline" Welcome to my site.
371
+ ~~~
321
372
 
322
373
  Or nest it. You must use a pipe or an apostrophe to escape processing
323
374
 
324
- body
325
- h1 id="headline"
326
- | Welcome to my site.
375
+
376
+ ~~~ slim
377
+ body
378
+ h1 id="headline"
379
+ | Welcome to my site.
380
+ ~~~
381
+
382
+ Or enable and rely on smart text instead
383
+
384
+ ~~~ slim
385
+ body
386
+ h1 id="headline"
387
+ Welcome to my site.
388
+ ~~~
327
389
 
328
390
  ### Dynamic content (`=` and `==`)
329
391
 
330
392
  Can make the call on the same line
331
393
 
332
- body
333
- h1 id="headline" = page_headline
394
+ ~~~ slim
395
+ body
396
+ h1 id="headline" = page_headline
397
+ ~~~
334
398
 
335
399
  Or nest it.
336
400
 
337
- body
338
- h1 id="headline"
339
- = page_headline
401
+ ~~~ slim
402
+ body
403
+ h1 id="headline"
404
+ = page_headline
405
+ ~~~
340
406
 
341
407
  ### Attributes
342
408
 
343
409
  You write attributes directly after the tag. For normal text attributes you must use double `"` or single quotes `'` (Quoted attributes).
344
410
 
345
- a href="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
411
+ ~~~ slim
412
+ a href="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
413
+ ~~~
346
414
 
347
415
  You can use text interpolation in the quoted attributes.
348
416
 
@@ -350,56 +418,74 @@ You can use text interpolation in the quoted attributes.
350
418
 
351
419
  If a delimiter makes the syntax more readable for you,
352
420
  you can use the characters `{...}`, `(...)`, `[...]` to wrap the attributes.
353
- You can configure these symbols (See option `:attr_delims`).
421
+ You can configure these symbols (See option `:attr_list_delims`).
354
422
 
355
- body
356
- h1(id="logo") = page_logo
357
- h2[id="tagline" class="small tagline"] = page_tagline
423
+ ~~~ slim
424
+ body
425
+ h1(id="logo") = page_logo
426
+ h2[id="tagline" class="small tagline"] = page_tagline
427
+ ~~~
358
428
 
359
429
  If you wrap the attributes, you can spread them across multiple lines:
360
430
 
361
- h2[id="tagline"
362
- class="small tagline"] = page_tagline
431
+ ~~~ slim
432
+ h2[id="tagline"
433
+ class="small tagline"] = page_tagline
434
+ ~~~
363
435
 
364
436
  You may use spaces around the wrappers and assignments:
365
437
 
366
- h1 id = "logo" = page_logo
367
- h2 [ id = "tagline" ] = page_tagline
438
+ ~~~ slim
439
+ h1 id = "logo" = page_logo
440
+ h2 [ id = "tagline" ] = page_tagline
441
+ ~~~
368
442
 
369
443
  #### Quoted attributes
370
444
 
371
445
  Example:
372
446
 
373
- a href="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
447
+ ~~~ slim
448
+ a href="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
449
+ ~~~
374
450
 
375
451
  You can use text interpolation in the quoted attributes:
376
452
 
377
- a href="http://#{url}" Goto the #{url}
453
+ ~~~ slim
454
+ a href="http://#{url}" Goto the #{url}
455
+ ~~~
378
456
 
379
457
  The attribute value will be escaped by default. Use == if you want to disable escaping in the attribute.
380
458
 
381
- a href=="&amp;"
459
+ ~~~ slim
460
+ a href=="&amp;"
461
+ ~~~
382
462
 
383
463
  You can break quoted attributes with backslash `\`
384
464
 
385
- a data-title="help" data-content="extremely long help text that goes on\
386
- and one and one and then starts over...."
465
+ ~~~ slim
466
+ a data-title="help" data-content="extremely long help text that goes on\
467
+ and one and one and then starts over...."
468
+ ~~~
387
469
 
388
470
  #### Ruby attributes
389
471
 
390
472
  Write the ruby code directly after the `=`. If the code contains spaces you have to wrap
391
473
  the code into parentheses `(...)`. You can also directly write hashes `{...}` and arrays `[...]`.
392
474
 
393
- body
394
- table
395
- - for user in users
396
- td id="user_#{user.id}" class=user.role
397
- a href=user_action(user, :edit) Edit #{user.name}
398
- a href=(path_to_user user) = user.name
475
+ ~~~ slim
476
+ body
477
+ table
478
+ - for user in users
479
+ td id="user_#{user.id}" class=user.role
480
+ a href=user_action(user, :edit) Edit #{user.name}
481
+ a href=(path_to_user user) = user.name
482
+ ~~~
399
483
 
400
484
  The attribute value will be escaped by default. Use == if you want to disable escaping in the attribute.
401
485
 
402
- a href==action_path(:start)
486
+ ~~~ slim
487
+ a href==action_path(:start)
488
+ ~~~
403
489
 
404
490
  You can also break ruby attributes with backslash `\` or trailing `,` as describe for control sections.
405
491
 
@@ -408,70 +494,92 @@ You can also break ruby attributes with backslash `\` or trailing `,` as describ
408
494
  The attribute values `true`, `false` and `nil` are interpreted
409
495
  as booleans. If you use the attribute wrapper you can omit the attribute assigment.
410
496
 
411
- input type="text" disabled="disabled"
412
- input type="text" disabled=true
413
- input(type="text" disabled)
497
+ ~~~ slim
498
+ input type="text" disabled="disabled"
499
+ input type="text" disabled=true
500
+ input(type="text" disabled)
414
501
 
415
- input type="text"
416
- input type="text" disabled=false
417
- input type="text" disabled=nil
502
+ input type="text"
503
+ input type="text" disabled=false
504
+ input type="text" disabled=nil
505
+ ~~~
418
506
 
419
507
  #### Attribute merging
420
508
 
421
509
  You can configure attributes to be merged if multiple are given (See option `:merge_attrs`). In the default configuration
422
510
  this is done for class attributes with the white space as delimiter.
423
511
 
424
- a.menu class="highlight" href="http://slim-lang.com/" Slim-lang.com
512
+ ~~~ slim
513
+ a.menu class="highlight" href="http://slim-lang.com/" Slim-lang.com
514
+ ~~~
425
515
 
426
516
  This renders as
427
517
 
428
- <a class="menu highlight" href="http://slim-lang.com/">Slim-lang.com</a>
518
+ ~~~ html
519
+ <a class="menu highlight" href="http://slim-lang.com/">Slim-lang.com</a>
520
+ ~~~
429
521
 
430
522
  You can also use an `Array` as attribute value and the array elements will be merged using the delimiter.
431
523
 
432
- a class=["menu","highlight"]
433
- a class=:menu,:highlight
524
+ ~~~ slim
525
+ a class=["menu","highlight"]
526
+ a class=:menu,:highlight
527
+ ~~~
434
528
 
435
529
  #### Splat attributes `*`
436
530
 
437
531
  The splat shortcut allows you turn a hash in to attribute/value pairs
438
532
 
439
- .card*{'data-url'=>place_path(place), 'data-id'=>place.id} = place.name
533
+ ~~~ slim
534
+ .card*{'data-url'=>place_path(place), 'data-id'=>place.id} = place.name
535
+ ~~~
440
536
 
441
537
  renders as
442
538
 
443
- <div class="card" data-id="1234" data-url="/place/1234">Slim's house</div>
539
+ ~~~ html
540
+ <div class="card" data-id="1234" data-url="/place/1234">Slim's house</div>
541
+ ~~~
444
542
 
445
543
  You can also use methods or instance variables which return a hash as shown here:
446
544
 
447
- .card *method_which_returns_hash = place.name
448
- .card *@hash_instance_variable = place.name
545
+ ~~~ slim
546
+ .card *method_which_returns_hash = place.name
547
+ .card *@hash_instance_variable = place.name
548
+ ~~~
449
549
 
450
550
  The hash attributes which support attribute merging (see Slim option `:merge_attrs`) can be given as an `Array`
451
551
 
452
- .first *{:class => [:second, :third]} Text
552
+ ~~~ slim
553
+ .first *{:class => [:second, :third]} Text
554
+ ~~~
453
555
 
454
556
  renders as
455
557
 
456
- div class="first second third"
558
+ ~~~ html
559
+ div class="first second third"
560
+ ~~~
457
561
 
458
562
  #### Dynamic tags `*`
459
563
 
460
564
  You can create completely dynamic tags using the splat attributes. Just create a method which returns a hash
461
565
  with the :tag key.
462
566
 
463
- ruby:
464
- def a_unless_current
465
- @page_current ? {:tag => 'span'} : {:tag => 'a', :href => 'http://slim-lang.com/'}
466
- end
467
- - @page_current = true
468
- *a_unless_current Link
469
- - @page_current = false
470
- *a_unless_current Link
567
+ ~~~ slim
568
+ ruby:
569
+ def a_unless_current
570
+ @page_current ? {:tag => 'span'} : {:tag => 'a', :href => 'http://slim-lang.com/'}
571
+ end
572
+ - @page_current = true
573
+ *a_unless_current Link
574
+ - @page_current = false
575
+ *a_unless_current Link
576
+ ~~~
471
577
 
472
578
  renders as
473
579
 
474
- <span>Link</span><a href="http://slim-lang.com/">Link</a>
580
+ ~~~ html
581
+ <span>Link</span><a href="http://slim-lang.com/">Link</a>
582
+ ~~~
475
583
 
476
584
  ### Shortcuts
477
585
 
@@ -479,15 +587,21 @@ renders as
479
587
 
480
588
  You can define custom tag shortcuts by setting the option `:shortcut`.
481
589
 
482
- Slim::Engine.set_default_options :shortcut => {'c' => {:tag => 'container'}, '#' => {:attr => 'id'}, '.' => {:attr => 'class'} }
590
+ ~~~ ruby
591
+ Slim::Engine.set_default_options :shortcut => {'c' => {:tag => 'container'}, '#' => {:attr => 'id'}, '.' => {:attr => 'class'} }
592
+ ~~~
483
593
 
484
594
  We can use it in Slim code like this
485
595
 
486
- c.content Text
596
+ ~~~ slim
597
+ c.content Text
598
+ ~~~
487
599
 
488
600
  which renders to
489
601
 
490
- <container class="content">Text</container>
602
+ ~~~ html
603
+ <container class="content">Text</container>
604
+ ~~~
491
605
 
492
606
  #### Attribute shortcuts
493
607
 
@@ -495,65 +609,87 @@ You can define custom shortcuts (Similar to `#` for id and `.` for class).
495
609
 
496
610
  In this example we add `&` to create a shortcut for the input elements with type attribute.
497
611
 
498
- Slim::Engine.set_default_options :shortcut => {'&' => {:tag => 'input', :attr => 'type'}, '#' => {:attr => 'id'}, '.' => {:attr => 'class'}}
612
+ ~~~ ruby
613
+ Slim::Engine.set_default_options :shortcut => {'&' => {:tag => 'input', :attr => 'type'}, '#' => {:attr => 'id'}, '.' => {:attr => 'class'}}
614
+ ~~~
499
615
 
500
616
  We can use it in Slim code like this
501
617
 
502
- &text name="user"
503
- &password name="pw"
504
- &submit
618
+ ~~~ slim
619
+ &text name="user"
620
+ &password name="pw"
621
+ &submit
622
+ ~~~
505
623
 
506
624
  which renders to
507
625
 
508
- <input type="text" name="user" />
509
- <input type="password" name="pw" />
510
- <input type="submit" />
626
+ ~~~ html
627
+ <input type="text" name="user" />
628
+ <input type="password" name="pw" />
629
+ <input type="submit" />
630
+ ~~~
511
631
 
512
632
  In another example we add `@` to create a shortcut for the role attribute.
513
633
 
514
- Slim::Engine.set_default_options :shortcut => {'@' => {:attr => 'role'}, '#' => {:attr => 'id'}, '.' => {:attr => 'class'}}
634
+ ~~~ ruby
635
+ Slim::Engine.set_default_options :shortcut => {'@' => {:attr => 'role'}, '#' => {:attr => 'id'}, '.' => {:attr => 'class'}}
636
+ ~~~
515
637
 
516
638
  We can use it in Slim code like this
517
639
 
518
- .person@admin = person.name
640
+ ~~~ slim
641
+ .person@admin = person.name
642
+ ~~~
519
643
 
520
644
  which renders to
521
645
 
522
- <div class="person" role="admin">Daniel</div>
646
+ ~~~ html
647
+ <div class="person" role="admin">Daniel</div>
648
+ ~~~
523
649
 
524
650
  You can also set multiple attributes at once using one shortcut.
525
651
 
526
- Slim::Engine.set_default_options :shortcut => {'@' => {:attr => %w(data-role role)}}
652
+ ~~~ ruby
653
+ Slim::Engine.set_default_options :shortcut => {'@' => {:attr => %w(data-role role)}}
654
+ ~~~
527
655
 
528
656
  We can use it in Slim code like this
529
657
 
530
- .person@admin = person.name
658
+ ~~~ slim
659
+ .person@admin = person.name
660
+ ~~~
531
661
 
532
662
  which renders to
533
663
 
534
- <div class="person" role="admin" data-role="admin">Daniel</div>
664
+ ~~~ html
665
+ <div class="person" role="admin" data-role="admin">Daniel</div>
666
+ ~~~
535
667
 
536
668
  #### ID shortcut `#` and class shortcut `.`
537
669
 
538
- Similarly to Haml, you can specify the `id` and `class` attributes in the following shortcut form
670
+ You can specify the `id` and `class` attributes in the following shortcut form
539
671
 
540
- body
541
- h1#headline
542
- = page_headline
543
- h2#tagline.small.tagline
544
- = page_tagline
545
- .content
546
- = show_content
672
+ ~~~ slim
673
+ body
674
+ h1#headline
675
+ = page_headline
676
+ h2#tagline.small.tagline
677
+ = page_tagline
678
+ .content
679
+ = show_content
680
+ ~~~
547
681
 
548
682
  This is the same as
549
683
 
550
- body
551
- h1 id="headline"
552
- = page_headline
553
- h2 id="tagline" class="small tagline"
554
- = page_tagline
555
- div class="content"
556
- = show_content
684
+ ~~~ slim
685
+ body
686
+ h1 id="headline"
687
+ = page_headline
688
+ h2 id="tagline" class="small tagline"
689
+ = page_tagline
690
+ div class="content"
691
+ = show_content
692
+ ~~~
557
693
 
558
694
  ## Helpers, capturing and includes
559
695
 
@@ -576,23 +712,76 @@ end
576
712
 
577
713
  which is included in the scope that executes the Slim template code. The helper can then be used in the Slim template as follows
578
714
 
579
- p
580
- = headline do
581
- ' Hello
582
- = user.name
715
+ ~~~ slim
716
+ p
717
+ = headline do
718
+ ' Hello
719
+ = user.name
720
+ ~~~
583
721
 
584
722
  The content in the `do` block is then captured automatically and passed to the helper via `yield`. As a syntactic
585
723
  sugar you can omit the `do` keyword and write only
586
724
 
587
- p
588
- = headline
589
- ' Hello
590
- = user.name
725
+ ~~~ slim
726
+ p
727
+ = headline
728
+ ' Hello
729
+ = user.name
730
+ ~~~
731
+
732
+ ### Capturing to local variables
591
733
 
592
- It has been requested many times to support includes of subtemplates in Slim. Up to now this has not been implemented as a core feature
593
- but you can easily get it by writing your own helper. The includes will be executed at runtime.
734
+ Using the `Binding` you can capture to local variables as follows:
594
735
 
595
736
  ~~~ruby
737
+ module Helpers
738
+ def capture_to_local(var, &block)
739
+ set_var = block.binding.eval("lambda {|x| #{var} = x }")
740
+ # In Rails we have to use capture!
741
+ # If we are using Slim without a framework (Plain Tilt),
742
+ # you can just yield to get the captured block.
743
+ set_var.call(defined?(::Rails) ? capture(&block) : yield)
744
+ end
745
+ end
746
+ ~~~
747
+
748
+ The helper can then be used in the Slim template as follows
749
+
750
+ ~~~ slim
751
+ / The captured_content variable must be known by the Binding beforehand.
752
+ = capture_to_local captured_content=:captured_content
753
+ p This will be captured in the variable captured_content
754
+ = captured_content
755
+ ~~~
756
+
757
+ Another interesting use case is to use an enumerable and capture for each element. The helper could look like this
758
+
759
+ ~~~ ruby
760
+ module Capture
761
+ def capture(var, enumerable = nil, &block)
762
+ value = enumerable ? enumerable.map(&block) : yield
763
+ block.binding.eval("lambda {|x| #{var} = x }").call(value)
764
+ nil
765
+ end
766
+ end
767
+ ~~~
768
+
769
+ and it would be used as follows
770
+
771
+ ~~~ slim
772
+ - links = { 'http://slim-lang.com' => 'The Slim Template Language' }
773
+ = capture link_list=:link_list, links do |url, text|
774
+ a href=url = text
775
+ ~~~
776
+
777
+ Afterwards, `link_list` contains the captured content.
778
+
779
+ ### Include helper
780
+
781
+ If you want includes which are processed at compile time, you can take a look at [Include partials](doc/include.md).
782
+ However you can also execute subtemplates at runtime (similar to Rails' `#render`). You have to write your own include helper:
783
+
784
+ ~~~ ruby
596
785
  module Helpers
597
786
  def include_slim(name, options = {}, &block)
598
787
  Slim::Template.new("#{name}.slim", options).render(self, &block)
@@ -602,8 +791,10 @@ end
602
791
 
603
792
  This helper can then be used as follows
604
793
 
605
- nav= include_slim 'menu'
606
- section= include_slim 'content'
794
+ ~~~ slim
795
+ nav= include_slim 'menu'
796
+ section= include_slim 'content'
797
+ ~~~
607
798
 
608
799
  However this helper doesn't do any caching. You should therefore implement a more intelligent version of the helper which
609
800
  fits your purposes. You should also be aware that most frameworks already bring their own include helper, e.g. Rails has `render`.
@@ -612,14 +803,18 @@ fits your purposes. You should also be aware that most frameworks already bring
612
803
 
613
804
  Use standard Ruby interpolation. The text will be html escaped by default.
614
805
 
615
- body
616
- h1 Welcome #{current_user.name} to the show.
617
- | Unescaped #{{content}} is also possible.
806
+ ~~~ slim
807
+ body
808
+ h1 Welcome #{current_user.name} to the show.
809
+ | Unescaped #{{content}} is also possible.
810
+ ~~~
618
811
 
619
812
  To escape the interpolation (i.e. render as is)
620
813
 
621
- body
622
- h1 Welcome \#{current_user.name} to the show.
814
+ ~~~ slim
815
+ body
816
+ h1 Welcome \#{current_user.name} to the show.
817
+ ~~~
623
818
 
624
819
  ## Embedded engines (Markdown, ...)
625
820
 
@@ -627,13 +822,17 @@ Thanks to [Tilt](https://github.com/rtomayko/tilt), Slim has impressive support
627
822
 
628
823
  Examples:
629
824
 
630
- coffee:
631
- square = (x) -> x * x
825
+ ~~~ slim
826
+ coffee:
827
+ square = (x) -> x * x
632
828
 
633
- markdown:
634
- #Header
635
- Hello from #{"Markdown!"}
636
- Second Line!
829
+ markdown:
830
+ #Header
831
+ Hello from #{"Markdown!"}
832
+ Second Line!
833
+
834
+ p: markdown: Tag with **inline** markdown!
835
+ ~~~
637
836
 
638
837
  Supported engines:
639
838
 
@@ -659,7 +858,9 @@ Supported engines:
659
858
 
660
859
  The embedded engines can be configured in Slim by setting the options directly on the `Slim::Embedded` filter. Example:
661
860
 
662
- Slim::Embedded.default_options[:markdown] = {:auto_ids => false}
861
+ ~~~ ruby
862
+ Slim::Embedded.default_options[:markdown] = {:auto_ids => false}
863
+ ~~~
663
864
 
664
865
  ## Configuring Slim
665
866
 
@@ -668,42 +869,52 @@ The way how you configure Slim depends a bit on the compilation mechanism (Rails
668
869
 
669
870
  ### Default options
670
871
 
671
- # Indent html for pretty debugging and do not sort attributes (Ruby 1.8)
672
- Slim::Engine.set_default_options :pretty => true, :sort_attrs => false
872
+ ~~~ ruby
873
+ # Indent html for pretty debugging and do not sort attributes (Ruby 1.8)
874
+ Slim::Engine.set_default_options :pretty => true, :sort_attrs => false
673
875
 
674
- # Indent html for pretty debugging and do not sort attributes (Ruby 1.9)
675
- Slim::Engine.set_default_options pretty: true, sort_attrs: false
876
+ # Indent html for pretty debugging and do not sort attributes (Ruby 1.9)
877
+ Slim::Engine.set_default_options pretty: true, sort_attrs: false
878
+ ~~~
676
879
 
677
880
  You can also access the option hash directly:
678
881
 
679
- Slim::Engine.default_options[:pretty] = true
882
+ ~~~ ruby
883
+ Slim::Engine.default_options[:pretty] = true
884
+ ~~~
680
885
 
681
886
  ### Setting options at runtime
682
887
 
683
888
  There are two ways to set options at runtime. For Tilt templates (`Slim::Template`) you can set
684
889
  the options when you instatiate the template:
685
890
 
686
- Slim::Template.new('template.slim', optional_option_hash).render(scope)
891
+ ~~~ ruby
892
+ Slim::Template.new('template.slim', optional_option_hash).render(scope)
893
+ ~~~
687
894
 
688
895
  The other possibility is to set the options per thread which is interesting mostly for Rails:
689
896
 
690
- Slim::Engine.with_options(option_hash) do
691
- # Any Slim engines which are created here use the option_hash
692
- # For example in Rails:
693
- render :page, :layout => true
694
- end
897
+ ~~~ ruby
898
+ Slim::Engine.with_options(option_hash) do
899
+ # Any Slim engines which are created here use the option_hash
900
+ # For example in Rails:
901
+ render :page, :layout => true
902
+ end
903
+ ~~~
695
904
 
696
905
  You have to be aware that the compiled engine code and the options are cached per template in Rails and you cannot change the option afterwards.
697
906
 
698
- # First render call
699
- Slim::Engine.with_options(:pretty => true) do
700
- render :page, :layout => true
701
- end
907
+ ~~~ ruby
908
+ # First render call
909
+ Slim::Engine.with_options(:pretty => true) do
910
+ render :page, :layout => true
911
+ end
702
912
 
703
- # Second render call
704
- Slim::Engine.with_options(:pretty => false) do
705
- render :page, :layout => true # :pretty is still true because it is cached
706
- end
913
+ # Second render call
914
+ Slim::Engine.with_options(:pretty => false) do
915
+ render :page, :layout => true # :pretty is still true because it is cached
916
+ end
917
+ ~~~
707
918
 
708
919
  ### Available options
709
920
 
@@ -718,7 +929,8 @@ There are a lot of them but the good thing is, that Slim checks the configuratio
718
929
  | String | :encoding | "utf-8" | Set encoding of template |
719
930
  | String | :default_tag | "div" | Default tag to be used if tag name is omitted |
720
931
  | Hash | :shortcut | \{'.' => {:attr => 'class'}, '#' => {:attr => 'id'}} | Attribute shortcuts |
721
- | Hash | :attr_delims | \{'(' => ')', '[' => ']', '{' => '}'} | Attribute delimiters |
932
+ | Hash | :code_attr_delims | \{'(' => ')', '[' => ']', '{' => '}'} | Attribute delimiters for Ruby code attributes |
933
+ | Hash | :attr_list_delims | \{'(' => ')', '[' => ']', '{' => '}'} | Attribute list delimiter |
722
934
  | Array&lt;Symbol,String&gt; | :enable_engines | nil <i>(All enabled)</i> | List of enabled embedded engines (whitelist) |
723
935
  | Array&lt;Symbol,String&gt; | :disable_engines | nil <i>(None disabled)</i> | List of disabled embedded engines (blacklist) |
724
936
  | Boolean | :disable_capture | false (true in Rails) | Disable capturing in blocks (blocks write to the default buffer |
@@ -753,15 +965,19 @@ options of the superclass. The option priorities are as follows:
753
965
 
754
966
  It is also possible to set options for superclasses like `Temple::Engine`. But this will affect all temple template engines then.
755
967
 
756
- Slim::Engine < Temple::Engine
757
- Slim::Compiler < Temple::Filter
968
+ ~~~ ruby
969
+ Slim::Engine < Temple::Engine
970
+ Slim::Compiler < Temple::Filter
971
+ ~~~
758
972
 
759
973
  ## Plugins
760
974
 
761
- Slim currently provides plugins for logic less mode and I18n. See the plugin documentation.
975
+ Slim currently provides plugins for logic less mode, includes and I18n. See the plugin documentation.
762
976
 
763
977
  * [Logic less mode](doc/logic_less.md)
978
+ * [Include partials](doc/include.md)
764
979
  * [Translator/I18n](doc/translator.md)
980
+ * [Smart text mode](doc/smart.md)
765
981
 
766
982
  ## Framework support
767
983
 
@@ -769,16 +985,19 @@ Slim currently provides plugins for logic less mode and I18n. See the plugin doc
769
985
 
770
986
  Slim uses [Tilt](https://github.com/rtomayko/tilt) to compile the generated code. If you want to use the Slim template directly, you can use the Tilt interface.
771
987
 
772
- Tilt.new['template.slim'].render(scope)
773
- Slim::Template.new('template.slim', optional_option_hash).render(scope)
774
- Slim::Template.new(optional_option_hash) { source }.render(scope)
988
+ ~~~ ruby
989
+ Tilt.new['template.slim'].render(scope)
990
+ Slim::Template.new('template.slim', optional_option_hash).render(scope)
991
+ Slim::Template.new(optional_option_hash) { source }.render(scope)
992
+ ~~~
775
993
 
776
994
  The optional option hash can have to options which were documented in the section above. The scope is the object in which the template
777
995
  code is executed.
778
996
 
779
997
  ### Sinatra
780
998
 
781
- <pre>require 'sinatra'
999
+ ~~~ ruby
1000
+ require 'sinatra'
782
1001
  require 'slim'
783
1002
 
784
1003
  get('/') { slim :index }
@@ -791,7 +1010,7 @@ html
791
1010
  title Sinatra With Slim
792
1011
  body
793
1012
  h1 Slim Is Fun!
794
- </pre>
1013
+ ~~~
795
1014
 
796
1015
  ### Rails
797
1016
 
@@ -816,11 +1035,12 @@ Usage: slimrb [options]
816
1035
  --trace Show a full traceback on error
817
1036
  -c, --compile Compile only but do not run
818
1037
  -e, --erb Convert to ERB
819
- -r, --rails Generate rails compatible code (Implies --compile)
1038
+ --rails Generate rails compatible code (Implies --compile)
1039
+ -r library Load library or plugin with -r slim/plugin
820
1040
  -t, --translator Enable translator plugin
821
1041
  -l, --logic-less Enable logic less plugin
822
1042
  -p, --pretty Produce pretty html
823
- -o, --option [NAME=CODE] Set slim option
1043
+ -o, --option name=code Set slim option
824
1044
  -h, --help Show this message
825
1045
  -v, --version Print version
826
1046
  </pre>
@@ -878,7 +1098,9 @@ There are plugins for various text editors (including the most important ones -
878
1098
  Run the benchmarks with `rake bench`. You can add the option `slow` to
879
1099
  run the slow parsing benchmark which needs more time. You can also increase the number of iterations.
880
1100
 
881
- rake bench slow=1 iterations=1000
1101
+ ~~~
1102
+ $ rake bench slow=1 iterations=1000
1103
+ ~~~
882
1104
 
883
1105
  We run the benchmarks for every commit on Travis-CI. Take a look at the newest benchmarking results: <http://travis-ci.org/slim-template/slim>
884
1106
 
@@ -895,14 +1117,16 @@ Slim is working well on all major Ruby implementations:
895
1117
 
896
1118
  * Ruby 1.8.7, 1.9.3 and 2.0.0
897
1119
  * Ruby EE
898
- * JRuby
1120
+ * JRuby 1.9 mode
899
1121
  * Rubinius 2.0
900
1122
 
901
1123
  ## Contributing
902
1124
 
903
1125
  If you'd like to help improve Slim, clone the project with Git by running:
904
1126
 
905
- $ git clone git://github.com/slim-template/slim
1127
+ ~~~
1128
+ $ git clone git://github.com/slim-template/slim
1129
+ ~~~
906
1130
 
907
1131
  Work your magic and then submit a pull request. We love pull requests!
908
1132
 
@@ -959,6 +1183,8 @@ Template Converters (HAML, ERB, ...):
959
1183
 
960
1184
  Language ports/Similar languages:
961
1185
 
1186
+ * [Sliq (Slim/Liquid integration)](https://github.com/slim-template/sliq)
1187
+ * [Slm (Slim port to Javascript)](https://github.com/slm-lang/slm)
962
1188
  * [Coffee script plugin for Slim](https://github.com/yury/coffee-views)
963
1189
  * [Clojure port of Slim](https://github.com/chaslemley/slim.clj)
964
1190
  * [Hamlet.rb (Similar template language)](https://github.com/gregwebs/hamlet.rb)
@@ -968,3 +1194,4 @@ Language ports/Similar languages:
968
1194
  * [Haml (Older engine which inspired Slim)](https://github.com/haml/haml)
969
1195
  * [Jade (Similar engine for javascript)](https://github.com/visionmedia/jade)
970
1196
  * [Sweet (Similar engine which also allows to write classes and functions)](https://github.com/joaomdmoura/sweet)
1197
+ * [Amber (Similar engine for Go)](https://github.com/eknkc/amber)