slim 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -1
- data/CHANGES +6 -0
- data/Gemfile +1 -3
- data/README.md +504 -207
- data/Rakefile +28 -12
- data/benchmarks/profile-render.rb +3 -3
- data/benchmarks/run-benchmarks.rb +104 -62
- data/benchmarks/run-diffbench.rb +21 -0
- data/bin/slimrb +1 -2
- data/lib/slim.rb +0 -2
- data/lib/slim/command.rb +12 -5
- data/lib/slim/compiler.rb +10 -15
- data/lib/slim/embedded_engine.rb +34 -16
- data/lib/slim/engine.rb +4 -51
- data/lib/slim/filter.rb +5 -5
- data/lib/slim/grammar.rb +1 -1
- data/lib/slim/interpolation.rb +1 -3
- data/lib/slim/logic_less.rb +6 -0
- data/lib/slim/{sections.rb → logic_less/filter.rb} +16 -16
- data/lib/slim/logic_less/wrapper.rb +64 -0
- data/lib/slim/parser.rb +9 -11
- data/lib/slim/translator.rb +117 -0
- data/lib/slim/version.rb +1 -1
- data/slim.gemspec +1 -1
- data/test/slim/helper.rb +0 -5
- data/test/slim/{test_sections.rb → logic_less/test_logic_less.rb} +16 -15
- data/test/slim/{test_wrapper.rb → logic_less/test_wrapper.rb} +4 -12
- data/test/slim/test_encoding.rb +6 -0
- data/test/slim/test_slim_template.rb +4 -0
- data/test/slim/translator/test_translator.rb +64 -0
- metadata +69 -24
- data/lib/slim/wrapper.rb +0 -57
data/.travis.yml
CHANGED
@@ -7,7 +7,6 @@ rvm:
|
|
7
7
|
- rbx-19mode
|
8
8
|
env:
|
9
9
|
- "TASK=test"
|
10
|
-
- "TASK=test TEMPLE=master"
|
11
10
|
- "TASK=test:rails RAILS=master"
|
12
11
|
- "TASK=test:rails RAILS=3.0.11"
|
13
12
|
- "TASK=test:rails RAILS=3.1.3"
|
@@ -20,6 +19,9 @@ matrix:
|
|
20
19
|
env: "TASK=test:rails RAILS=master"
|
21
20
|
- rvm: rbx-18mode
|
22
21
|
env: "TASK=test:rails RAILS=master"
|
22
|
+
allow_failures:
|
23
|
+
- rvm: ruby-head
|
24
|
+
- env: "TASK=test:rails RAILS=master"
|
23
25
|
script: "bundle exec rake test:ci"
|
24
26
|
notifications:
|
25
27
|
email: false
|
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
1.3.0
|
2
|
+
|
3
|
+
* Parser wraps text blocks in [:slim, :text, ...] (Used by Translator/I18n plugin)
|
4
|
+
* Added Translator/I18n plugin which uses GetText or FastGettext (require 'slim/translator')
|
5
|
+
* Moved logic less mode out of the core to plugin (require 'slim/logic_less')
|
6
|
+
|
1
7
|
1.2.2
|
2
8
|
|
3
9
|
* Fix issue #264
|
data/Gemfile
CHANGED
@@ -2,15 +2,13 @@ source :rubygems
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
if ENV['TEMPLE'] == 'master'
|
5
|
+
if ENV['TRAVIS'] || ENV['TEMPLE'] == 'master'
|
6
6
|
gem 'temple', :git => 'git://github.com/judofyr/temple.git'
|
7
7
|
end
|
8
8
|
|
9
9
|
if ENV['RAILS']
|
10
10
|
if ENV['RAILS'] == 'master'
|
11
11
|
gem 'rails', :git => 'git://github.com/rails/rails.git'
|
12
|
-
# FIXME: Rails Gemfile is invalid!
|
13
|
-
gem 'journey', :git => 'git://github.com/rails/journey.git'
|
14
12
|
else
|
15
13
|
gem 'rails', "= #{ENV['RAILS']}"
|
16
14
|
end
|
data/README.md
CHANGED
@@ -1,19 +1,27 @@
|
|
1
1
|
# Slim
|
2
2
|
|
3
|
+
|
4
|
+
[![Build Status](https://secure.travis-ci.org/stonean/slim.png?branch=master)](http://travis-ci.org/stonean/slim) [![Dependency Status](https://gemnasium.com/stonean/slim.png?travis)](https://gemnasium.com/stonean/slim) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/stonean/slim)
|
5
|
+
|
3
6
|
Slim is a template language whose goal is to reduce the view syntax to the essential parts without becoming cryptic.
|
4
7
|
|
8
|
+
## Introduction
|
5
9
|
|
6
|
-
|
10
|
+
### What is Slim?
|
7
11
|
|
8
|
-
Slim is a fast, lightweight templating engine with support for __Rails 3__. It has been tested on
|
12
|
+
Slim is a fast, lightweight templating engine with support for __Rails 3__. It has been heavily tested on all major ruby implementations. We use
|
13
|
+
continous integration (travis-ci).
|
9
14
|
|
10
15
|
Slim's core syntax is guided by one thought: "What's the minimum required to make this work".
|
11
16
|
|
12
|
-
As more people have contributed to Slim, there have been
|
17
|
+
As more people have contributed to Slim, there have been syntax additions influenced from their use of [Haml](https://github.com/nex3/haml) and [Jade](https://github.com/visionmedia/jade). The Slim team is open to these additions because we know beauty is in the eye of the beholder.
|
13
18
|
|
14
19
|
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).
|
15
20
|
|
16
|
-
|
21
|
+
The architecture of Temple is very flexible and allows the extension of the parsing and compilation process without monkey-patching. This is used
|
22
|
+
by the logic-less plugin and the translator plugin which provides I18n.
|
23
|
+
|
24
|
+
### Why use Slim?
|
17
25
|
|
18
26
|
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.
|
19
27
|
|
@@ -21,42 +29,15 @@ Slim was born to bring a minimalist syntax approach with speed. If people chose
|
|
21
29
|
|
22
30
|
___Yes, Slim is speedy!___ Benchmarks are provided at the end of this README file. Don't trust the numbers? That's as it should be. Therefore we provide a benchmark rake task so you could test it yourself (`rake bench`).
|
23
31
|
|
24
|
-
|
32
|
+
### How to start?
|
25
33
|
|
26
34
|
Install Slim as a gem:
|
27
35
|
|
28
36
|
gem install slim
|
29
37
|
|
30
|
-
Include Slim in your Gemfile
|
31
|
-
|
32
|
-
gem 'slim'
|
33
|
-
|
34
|
-
That's it! Now, just use the .slim extension and you're good to go.
|
35
|
-
|
36
|
-
If you want to use the Slim template directly, you can use the Tilt interface:
|
37
|
-
|
38
|
-
Tilt.new['template.slim'].render(scope)
|
39
|
-
Slim::Template.new(filename, optional_option_hash).render(scope)
|
40
|
-
Slim::Template.new(optional_option_hash) { source }.render(scope)
|
41
|
-
|
42
|
-
## Syntax Highlighters
|
43
|
-
|
44
|
-
There are plugins for Vim, Emacs, Textmate and Espresso text editor:
|
45
|
-
|
46
|
-
* [Vim](https://github.com/bbommarito/vim-slim)
|
47
|
-
* [Textmate](https://github.com/fredwu/ruby-slim-tmbundle)
|
48
|
-
* [Emacs](https://github.com/minad/emacs-slim)
|
49
|
-
* [Espresso text editor](https://github.com/CiiDub/Slim-Sugar)
|
50
|
-
|
51
|
-
## Template Converters
|
52
|
-
|
53
|
-
For Haml, there is a [Haml2Slim converter](https://github.com/fredwu/haml2slim). For HTML, there is a [HTML2Slim converter](https://github.com/joaomilho/html2slim).
|
54
|
-
|
55
|
-
## The syntax
|
38
|
+
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.
|
56
39
|
|
57
|
-
|
58
|
-
|
59
|
-
Slim's syntax has been influenced by both _Haml_ and _Jade_.
|
40
|
+
### Syntax example
|
60
41
|
|
61
42
|
Here's a quick example to demonstrate what a Slim template looks like:
|
62
43
|
|
@@ -65,135 +46,295 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
65
46
|
head
|
66
47
|
title Slim Examples
|
67
48
|
meta name="keywords" content="template language"
|
49
|
+
meta name="author" content=author
|
50
|
+
link rel="icon" type="image/png" href=file_path("favicon.png")
|
51
|
+
javascript:
|
52
|
+
alert('Slim supports embedded javascript!')
|
68
53
|
|
69
54
|
body
|
70
55
|
h1 Markup examples
|
71
|
-
|
72
|
-
|
56
|
+
|
57
|
+
#content
|
58
|
+
p This example shows you how a basic Slim file looks like.
|
73
59
|
|
74
60
|
= yield
|
75
61
|
|
76
62
|
- if items.any?
|
77
|
-
table
|
63
|
+
table#items
|
78
64
|
- for item in items do
|
79
65
|
tr
|
80
|
-
td = item.name
|
81
|
-
td = item.price
|
66
|
+
td.name = item.name
|
67
|
+
td.price = item.price
|
82
68
|
- else
|
83
69
|
p No items found
|
84
70
|
|
85
71
|
#footer
|
86
|
-
|
72
|
+
= render 'footer'
|
73
|
+
| Copyright © #{year} #{author}
|
87
74
|
|
88
|
-
|
75
|
+
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.
|
89
76
|
|
90
|
-
|
91
|
-
| $(content).do_something();
|
77
|
+
## Line indicators
|
92
78
|
|
79
|
+
### Text `|`
|
93
80
|
|
94
|
-
|
81
|
+
The pipe tells Slim to just copy the line. It essentially escapes any processing.
|
82
|
+
Each following line that is indented greater than the backtick is copied over.
|
95
83
|
|
96
|
-
|
84
|
+
body
|
85
|
+
p
|
86
|
+
|
|
87
|
+
This is a test of the text block.
|
97
88
|
|
98
|
-
|
89
|
+
The parsed result of the above:
|
99
90
|
|
100
|
-
>
|
91
|
+
<body><p>This is a test of the text block.</p></body>
|
101
92
|
|
102
|
-
|
93
|
+
The left margin is set at the indent of the backtick + one space.
|
94
|
+
Any additional spaces will be copied over.
|
103
95
|
|
104
|
-
|
96
|
+
body
|
97
|
+
p
|
98
|
+
| This line is on the left margin.
|
99
|
+
This line will have one space in front of it.
|
100
|
+
This line will have two spaces in front of it.
|
101
|
+
And so on...
|
105
102
|
|
106
|
-
|
103
|
+
### Text with trailing space `'`
|
107
104
|
|
108
|
-
|
105
|
+
The single quote tells Slim to copy the line (similar to |), but makes sure that a single trailing space is appended.
|
109
106
|
|
110
|
-
|
107
|
+
### Control code `-`
|
111
108
|
|
112
|
-
|
109
|
+
The dash denotes control code. Examples of control code are loops and conditionals. `end` is forbidden behind `-`. Blocks are defined only by indentation.
|
110
|
+
If your ruby code needs to use multiple lines, append a `\` at the end of the lines.
|
113
111
|
|
114
|
-
|
112
|
+
### Dynamic output `=`
|
115
113
|
|
116
|
-
|
114
|
+
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 `\` at the end of the lines, for example:
|
117
115
|
|
118
|
-
|
116
|
+
= javascript_include_tag \
|
117
|
+
"jquery", \
|
118
|
+
"application"
|
119
119
|
|
120
|
-
|
120
|
+
### Output with trailing white space `='`
|
121
121
|
|
122
|
-
|
122
|
+
Same as the single equal sign (`=`), except that it adds a trailing whitespace.
|
123
123
|
|
124
|
-
|
124
|
+
### Output without HTML escaping `==`
|
125
125
|
|
126
|
-
|
126
|
+
Same as the single equal sign (`=`), but does not go through the `escape_html` method.
|
127
127
|
|
128
|
-
|
128
|
+
### Output without HTML escaping and trailing ws `=='`
|
129
129
|
|
130
|
-
|
130
|
+
Same as the double equal sign (`==`), except that it adds a trailing whitespace.
|
131
131
|
|
132
|
-
|
132
|
+
### Code comment `/`
|
133
133
|
|
134
|
+
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
|
134
135
|
|
135
|
-
|
136
|
+
body
|
137
|
+
p
|
138
|
+
/ This line won't get displayed.
|
139
|
+
Neither does this line.
|
140
|
+
/! This will get displayed as html comments.
|
136
141
|
|
137
|
-
|
138
|
-
`end` is forbidden behind `-`. Blocks are defined only by indentation.
|
142
|
+
The parsed result of the above:
|
139
143
|
|
140
|
-
|
141
|
-
If you nest content (e.g. put it on the next line), start the line with a pipe (`|`) or a single quote (`` ' ``).
|
144
|
+
<body><p><!--This will get displayed as html comments.--></p></body>
|
142
145
|
|
143
|
-
|
144
|
-
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.
|
146
|
+
### HTML comment `/!`
|
145
147
|
|
146
|
-
|
147
|
-
= javascript_include_tag \
|
148
|
-
"jquery", \
|
149
|
-
"application"
|
148
|
+
Use the forward slash immediately followed by an exclamation mark for html comments (` <!-- --> `).
|
150
149
|
|
151
|
-
###
|
150
|
+
### IE conditional comment `/![IE]`
|
152
151
|
|
153
|
-
|
154
|
-
|
152
|
+
/[ if IE ]
|
153
|
+
p Get a better browser.
|
155
154
|
|
156
|
-
|
157
|
-
|
158
|
-
|
155
|
+
<!--[if IE]><p>Get a better browser.</p><![endif]-->
|
156
|
+
|
157
|
+
## HTML tags
|
158
|
+
|
159
|
+
### Doctype tag
|
160
|
+
|
161
|
+
The doctype tag is a special tag which can be used to generate the complex doctypes in a very simple way.
|
162
|
+
|
163
|
+
XML VERSION
|
164
|
+
|
165
|
+
doctype xml
|
166
|
+
<?xml version="1.0" encoding="utf-8" ?>
|
167
|
+
|
168
|
+
doctype xml ISO-8859-1
|
169
|
+
<?xml version="1.0" encoding="iso-8859-1" ?>
|
170
|
+
|
171
|
+
XHTML DOCTYPES
|
172
|
+
|
173
|
+
doctype html
|
174
|
+
<!DOCTYPE html>
|
175
|
+
|
176
|
+
doctype 5
|
177
|
+
<!DOCTYPE html>
|
178
|
+
|
179
|
+
doctype 1.1
|
180
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
181
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
182
|
+
|
183
|
+
doctype strict
|
184
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
185
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
186
|
+
|
187
|
+
doctype frameset
|
188
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
|
189
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
|
190
|
+
|
191
|
+
doctype mobile
|
192
|
+
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN"
|
193
|
+
"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd">
|
194
|
+
|
195
|
+
doctype basic
|
196
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.1//EN"
|
197
|
+
"http://www.w3.org/TR/xhtml-basic/xhtml-basic11.dtd">
|
198
|
+
|
199
|
+
doctype transitional
|
200
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
201
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
202
|
+
|
203
|
+
HTML 4 DOCTYPES
|
204
|
+
|
205
|
+
doctype strict
|
206
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
207
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
208
|
+
|
209
|
+
doctype frameset
|
210
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
|
211
|
+
"http://www.w3.org/TR/html4/frameset.dtd">
|
212
|
+
|
213
|
+
doctype transitional
|
214
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
215
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
216
|
+
|
217
|
+
### Closed tags (trailing `/`)
|
218
|
+
|
219
|
+
You can close tags explicitly by appending a trailing `/`.
|
159
220
|
|
221
|
+
img src="image.png"/
|
160
222
|
|
161
|
-
|
223
|
+
Note, that this is usually not necessary since the standard html
|
224
|
+
tags (img, br, ...) are closed automatically.
|
162
225
|
|
163
|
-
|
164
|
-
|
226
|
+
### Inline tags
|
227
|
+
|
228
|
+
Sometimes you may want to be a little more compact and inline the tags.
|
229
|
+
|
230
|
+
ul
|
231
|
+
li.first: a href="/a" A link
|
232
|
+
li: a href="/b" B link
|
165
233
|
|
166
|
-
|
234
|
+
For readability, don't forget you can wrap the attributes.
|
167
235
|
|
168
|
-
|
236
|
+
ul
|
237
|
+
li.first: a[href="/a"] A link
|
238
|
+
li: a[href="/b"] B link
|
239
|
+
|
240
|
+
### Text content
|
241
|
+
|
242
|
+
Either start on the same line as the tag
|
169
243
|
|
170
244
|
body
|
171
245
|
h1 id="headline" Welcome to my site.
|
172
246
|
|
173
|
-
|
247
|
+
Or nest it. You must use a pipe or a backtick to escape processing
|
174
248
|
|
175
249
|
body
|
176
250
|
h1 id="headline"
|
177
251
|
| Welcome to my site.
|
178
252
|
|
179
|
-
###
|
253
|
+
### Dynamic content (`=` and `==`)
|
180
254
|
|
181
|
-
|
255
|
+
Can make the call on the same line
|
182
256
|
|
183
257
|
body
|
184
258
|
h1 id="headline" = page_headline
|
185
259
|
|
186
|
-
|
260
|
+
Or nest it.
|
187
261
|
|
188
262
|
body
|
189
263
|
h1 id="headline"
|
190
264
|
= page_headline
|
191
265
|
|
192
|
-
###
|
266
|
+
### Attributes
|
267
|
+
|
268
|
+
You write attributes directly after the tag. For normal text attributes you must use double `"` or single quotes `'` (Quoted attributes).
|
269
|
+
|
270
|
+
a href="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
|
271
|
+
|
272
|
+
You can use text interpolation in the quoted attributes.
|
273
|
+
|
274
|
+
#### Attributes wrapper
|
275
|
+
|
276
|
+
If a delimiter makes the syntax more readable for you,
|
277
|
+
you can use the characters `{...}`, `(...)`, `[...]` to wrap the attributes.
|
278
|
+
|
279
|
+
body
|
280
|
+
h1(id="logo") = page_logo
|
281
|
+
h2[id="tagline" class="small tagline"] = page_tagline
|
282
|
+
|
283
|
+
|
284
|
+
If you wrap the attributes, you can spread them across multiple lines:
|
285
|
+
|
286
|
+
h2[id="tagline"
|
287
|
+
class="small tagline"] = page_tagline
|
288
|
+
|
289
|
+
#### Quoted attributes
|
193
290
|
|
194
|
-
|
195
|
-
|
196
|
-
|
291
|
+
Example:
|
292
|
+
|
293
|
+
a href="http://slim-lang.com" title='Slim Homepage' Goto the Slim homepage
|
294
|
+
|
295
|
+
You can use text interpolation in the quoted attributes:
|
296
|
+
|
297
|
+
a href="http://#{url}" Goto the #{url}
|
298
|
+
|
299
|
+
#### Ruby attributes
|
300
|
+
|
301
|
+
Write the ruby code directly after the `=`. If the code contains spaces you have to wrap
|
302
|
+
the code into parentheses `(...)`, `{...}` or `[...]`. The code in the parentheses will be evaluated.
|
303
|
+
|
304
|
+
body
|
305
|
+
table
|
306
|
+
- for user in users do
|
307
|
+
td id="user_#{user.id}" class=user.role
|
308
|
+
a href=user_action(user, :edit) Edit #{user.name}
|
309
|
+
a href={path_to_user user} = user.name
|
310
|
+
|
311
|
+
Use == if you want to disable escaping in the attribute.
|
312
|
+
|
313
|
+
#### Boolean attributes
|
314
|
+
|
315
|
+
The attribute values `true`, `false` and `nil` are interpreted
|
316
|
+
as booleans. If you use the attribut wrapper you can omit the attribute assigment
|
317
|
+
|
318
|
+
input type="text" disabled="disabled"
|
319
|
+
input type="text" disabled=true
|
320
|
+
input(type="text" disabled)
|
321
|
+
|
322
|
+
input type="text"
|
323
|
+
input type="text" disabled=false
|
324
|
+
input type="text" disabled=nil
|
325
|
+
|
326
|
+
#### Splat attributes `*`
|
327
|
+
|
328
|
+
The splat shortcut allows you turn a hash in to attribute/value pairs
|
329
|
+
|
330
|
+
.card*{'data-url'=>place_path(place), 'data-id'=>place.id} = place.name
|
331
|
+
.card *method_which_returns_hash = place.name
|
332
|
+
|
333
|
+
<div class="card" data-id="1234" data-url="/place/1234">Slim's house</div>
|
334
|
+
|
335
|
+
#### ID shortcut `#` and class shortcut `.`
|
336
|
+
|
337
|
+
Similarly to Haml, you can specify the `id` and `class` attributes in the following shortcut form
|
197
338
|
|
198
339
|
body
|
199
340
|
h1#headline
|
@@ -203,7 +344,7 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
203
344
|
.content
|
204
345
|
= show_content
|
205
346
|
|
206
|
-
|
347
|
+
This is the same as
|
207
348
|
|
208
349
|
body
|
209
350
|
h1 id="headline"
|
@@ -213,159 +354,304 @@ Here's a quick example to demonstrate what a Slim template looks like:
|
|
213
354
|
div class="content"
|
214
355
|
= show_content
|
215
356
|
|
216
|
-
|
217
|
-
|
218
|
-
Sometimes you may want to be a little more compact and inline the tags.
|
357
|
+
#### Attribute shortcuts
|
219
358
|
|
220
|
-
|
221
|
-
li.first: a href="/a" A link
|
222
|
-
li: a href="/b" B link
|
359
|
+
You can define custom shortcuts (Similar to `#` for id and `.` for class).
|
223
360
|
|
224
|
-
|
361
|
+
In this example we add `@` to create a shortcut for the role attribute.
|
225
362
|
|
226
|
-
|
227
|
-
li.first: a[href="/a"] A link
|
228
|
-
li: a[href="/b"] B link
|
363
|
+
Slim::Engine.set_default_options :shortcut => {'@' => 'role', '#' => 'id', '.' => 'class'}
|
229
364
|
|
230
|
-
|
365
|
+
We can use it in Slim code like this
|
231
366
|
|
232
|
-
|
233
|
-
* Alternative 2: If the code doesn't contain any spaces you can omit the parentheses.
|
234
|
-
* Alternative 3: Use standard ruby interpolation #{}
|
367
|
+
.person@admin = person.name
|
235
368
|
|
236
|
-
|
369
|
+
which renders to
|
237
370
|
|
238
|
-
|
239
|
-
table
|
240
|
-
- for user in users do
|
241
|
-
td id="user_#{user.id}" class=user.role
|
242
|
-
a href=user_action(user, :edit) Edit #{user.name}
|
243
|
-
a href={path_to_user user} = user.name
|
371
|
+
<div class="person" role="admin">Daniel</div>
|
244
372
|
|
245
|
-
|
373
|
+
## Text interpolation
|
246
374
|
|
247
|
-
|
375
|
+
Use standard Ruby interpolation. The text will be html escaped by default.
|
248
376
|
|
249
377
|
body
|
250
378
|
h1 Welcome #{current_user.name} to the show.
|
251
379
|
| Unescaped #{{content}} is also possible.
|
252
380
|
|
253
|
-
|
381
|
+
To escape the interpolation (i.e. render as is)
|
254
382
|
|
255
383
|
body
|
256
384
|
h1 Welcome \#{current_user.name} to the show.
|
257
385
|
|
258
|
-
|
386
|
+
## Embedded engines (Markdown, ...)
|
387
|
+
|
388
|
+
Thanks to Tilt, Slim has impressive support for embedding other template engines.
|
389
|
+
|
390
|
+
Examples:
|
391
|
+
|
392
|
+
coffee:
|
393
|
+
square = (x) -> x * x
|
394
|
+
|
395
|
+
markdown:
|
396
|
+
#Header
|
397
|
+
Hello from #{"Markdown!"}
|
398
|
+
Second Line!
|
399
|
+
|
400
|
+
Supported engines:
|
401
|
+
|
402
|
+
<table>
|
403
|
+
<thead style="font-weight:bold"><tr><td>Engine</td><td>Filter</td><td>Required libraries</td><td>Type</td><td>Description</td></tr></thead>
|
404
|
+
<tbody>
|
405
|
+
<tr><td>Ruby</td><td>ruby:</td><td>none</td><td>Shortcut</td><td>Shortcut to embed ruby code</td></tr>
|
406
|
+
<tr><td>Javascript</td><td>javascript:</td><td>none</td><td>Shortcut</td><td>Shortcut to embed javascript code and wrap in script tag</td></tr>
|
407
|
+
<tr><td>CSS</td><td>css:</td><td>none</td><td>Shortcut</td><td>Shortcut to embed css code and wrap in style tag</td></tr>
|
408
|
+
<tr><td>Sass</td><td>sass:</td><td>sass</td><td>Compile time</td><td>Embed sass code and wrap in style tag</td></tr>
|
409
|
+
<tr><td>Scss</td><td>scss:</td><td>sass</td><td>Compile time</td><td>Embedd scss code and wrap in style tag</td></tr>
|
410
|
+
<tr><td>LessCSS</td><td>less:</td><td>less</td><td>Compile time</td><td>Embed less css code and wrap in style tag</td></tr>
|
411
|
+
<tr><td>Stylus</td><td>styl:</td><td>styl</td><td>Compile time</td><td>Embed stylus css code and wrap in style tag</td></tr>
|
412
|
+
<tr><td>CoffeeScript</td><td>coffee:</td><td>coffee-script (+node coffee)</td><td>Compile time</td><td>Compile coffee script code and wrap in script tag</td></tr>
|
413
|
+
<tr><td>RDiscount</td><td>markdown:</td><td>rdiscount/kramdown</td><td>Compile time + Interpolation</td><td>Compile markdown code and interpolate #\{variables} in text</td></tr>
|
414
|
+
<tr><td>RedCloth</td><td>textile:</td><td>redcloth</td><td>Compile time + Interpolation</td><td>Compile textile code and interpolate #\{variables} in text</td></tr>
|
415
|
+
<tr><td>Creole</td><td>creole:</td><td>creole</td><td>Compile time + Interpolation</td><td>Compile creole code and interpolate #\{variables} in text</td></tr>
|
416
|
+
<tr><td>Wikicloth</td><td>wiki:, mediawiki:</td><td>wikicloth</td><td>Compile time + Interpolation</td><td>Compile wiki code and interpolate #\{variables} in text</td></tr>
|
417
|
+
<tr><td>RDoc</td><td>rdoc:</td><td>rdoc</td><td>Compile time + Interpolation</td><td>Compile rdoc code and interpolate #\{variables} in text</td></tr>
|
418
|
+
<tr><td>Builder</td><td>builder:</td><td>builder</td><td>Precompiled</td><td>Embed builder code</td></tr>
|
419
|
+
<tr><td>Nokogiri</td><td>nokogiri:</td><td>nokogiri</td><td>Precompiled</td><td>Embed nokogiri builder code</td></tr>
|
420
|
+
<tr><td>ERB</td><td>erb:</td><td>none</td><td>Precompiled</td><td>Embed erb code</td></tr>
|
421
|
+
<tr><td>Liquid</td><td>liquid:</td><td>liquid</td><td>Runtime</td><td>Embed liquid code (Not recommended, no caching)</td></tr>
|
422
|
+
<tr><td>Radius</td><td>radius:</td><td>radius</td><td>Runtime</td><td>Embed radius code (Not recommended, no caching)</td></tr>
|
423
|
+
<tr><td>Markaby</td><td>markaby:</td><td>markaby</td><td>Runtime</td><td>Embed markaby code (Not recommended, no caching)</td></tr>
|
424
|
+
</tbody>
|
425
|
+
</table>
|
259
426
|
|
260
|
-
|
427
|
+
The embedded engines can be configured in Slim by setting the options directly on the `Slim::EmbeddedEngine` filter. Example:
|
261
428
|
|
262
|
-
|
263
|
-
h1 id="headline"
|
264
|
-
== page_headline
|
429
|
+
Slim::EmbeddedEngine.default_options[:markdown] = {:auto_ids => false}
|
265
430
|
|
266
|
-
|
431
|
+
## Configuring Slim
|
267
432
|
|
268
|
-
|
433
|
+
Slim and the underlying Temple framework are highly configurable. Unfortunately the way how you configure Slim depends on the compilation mechanism (Rails or Tilt).
|
434
|
+
It is always possible to set default options. This can be done in Rails' environment files. For instance, in config/environments/development.rb you probably want:
|
269
435
|
|
270
|
-
|
436
|
+
# Indent html for pretty debugging and do not sort attributes (Ruby 1.8)
|
437
|
+
Slim::Engine.set_default_options :pretty => true, :sort_attrs => false
|
271
438
|
|
272
|
-
|
273
|
-
|
274
|
-
the backtick is copied over.
|
439
|
+
# Indent html for pretty debugging and do not sort attributes (Ruby 1.9)
|
440
|
+
Slim::Engine.set_default_options pretty: true, sort_attrs: false
|
275
441
|
|
276
|
-
|
277
|
-
p
|
278
|
-
|
|
279
|
-
This is a test of the text block.
|
442
|
+
You can also access the option hash directly:
|
280
443
|
|
281
|
-
|
444
|
+
Slim::Engine.default_options[:pretty] = true
|
282
445
|
|
283
|
-
|
446
|
+
For developers who know more about Slim and Temple architecture it is possible to override default
|
447
|
+
options at different positions. Temple uses an inheritance mechanism to allow subclasses to override
|
448
|
+
options of the superclass. The option priorities are as follows:
|
284
449
|
|
285
|
-
|
286
|
-
Any additional spaces will be copied over.
|
450
|
+
Options passed at engine instantination > Slim::Template > Slim::Engine > Parser/Filter/Generator (e.g Slim::Parser, Slim::Compiler)
|
287
451
|
|
288
|
-
|
289
|
-
p
|
290
|
-
| This line is on the left margin.
|
291
|
-
This line will have one space in front of it.
|
292
|
-
This line will have two spaces in front of it.
|
293
|
-
And so on...
|
452
|
+
It is also possible to set options for superclasses like Temple::Engine. But this will affect all temple template engines then.
|
294
453
|
|
295
|
-
|
454
|
+
Slim::Engine > Temple::Engine
|
455
|
+
Slim::Compiler > Temple::Filter
|
296
456
|
|
297
|
-
|
457
|
+
The following options are exposed by the `Slim::Engine` and can be set with `Slim::Engine.set_default_options`.
|
298
458
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
459
|
+
<table>
|
460
|
+
<thead style="font-weight:bold"><tr><td>Type</td><td>Name</td><td>Default</td><td>Purpose</td></tr></thead>
|
461
|
+
<tbody>
|
462
|
+
<tr><td>String</td><td>:file</td><td>nil</td><td>Name of parsed file, set automatically by Slim::Template</td></tr>
|
463
|
+
<tr><td>Integer</td><td>:tabsize</td><td>4</td><td>Number of whitespaces per tab (used by the parser)</td></tr>
|
464
|
+
<tr><td>String</td><td>:encoding</td><td>"utf-8"</td><td>Set encoding of template</td></tr>
|
465
|
+
<tr><td>String</td><td>:default_tag</td><td>"div"</td><td>Default tag to be used if tag name is omitted</td></tr>
|
466
|
+
<tr><td>Hash</td><td>:shortcut</td><td>\{'.' => 'class', '#' => 'id'}</td><td>Attribute shortcuts</td></tr>
|
467
|
+
<tr><td>String list</td><td>:enable_engines</td><td>nil <i>(All enabled)</i></td><td>List of enabled embedded engines (whitelist)</td></tr>
|
468
|
+
<tr><td>String list</td><td>:disable_engines</td><td>nil <i>(None disabled)</i></td><td>List of disabled embedded engines (blacklist)</td></tr>
|
469
|
+
<tr><td>Boolean</td><td>:disable_capture</td><td>false (true in Rails)</td><td>Disable capturing in blocks (blocks write to the default buffer </td></tr>
|
470
|
+
<tr><td>Boolean</td><td>:disable_escape</td><td>false</td><td>Disable automatic escaping of strings</td></tr>
|
471
|
+
<tr><td>Boolean</td><td>:use_html_safe</td><td>false (true in Rails)</td><td>Use String#html_safe? from ActiveSupport (Works together with :disable_escape)</td></tr>
|
472
|
+
<tr><td>Symbol</td><td>:format</td><td>:xhtml</td><td>HTML output format (Possible formats :xhtml, :html4, :html5, :html)</td></tr>
|
473
|
+
<tr><td>String</td><td>:attr_wrapper</td><td>'"'</td><td>Character to wrap attributes in html (can be ' or ")</td></tr>
|
474
|
+
<tr><td>Hash</td><td>:attr_delimiter</td><td>\{'class' => ' '}</td><td>Joining character used if multiple html attributes are supplied (e.g. class="class1 class2")</td></tr>
|
475
|
+
<tr><td>Boolean</td><td>:sort_attrs</td><td>true</td><td>Sort attributes by name</td></tr>
|
476
|
+
<tr><td>Boolean</td><td>:remove_empty_attrs</td><td>true</td><td>Remove attributes with empty value</td></tr>
|
477
|
+
<tr><td>Boolean</td><td>:pretty</td><td>false</td><td>Pretty html indenting <b>(This is slower!)</b></td></tr>
|
478
|
+
<tr><td>String</td><td>:indent</td><td>' '</td><td>Indentation string</td></tr>
|
479
|
+
<tr><td>Boolean</td><td>:streaming</td><td>false (true in Rails > 3.1)</td><td>Enable output streaming</td></tr>
|
480
|
+
<tr><td>Class</td><td>:generator</td><td>Temple::Generators::ArrayBuffer/RailsOutputBuffer</td><td>Temple code generator (default generator generates array buffer)</td></tr>
|
481
|
+
</tbody>
|
482
|
+
</table>
|
304
483
|
|
305
|
-
|
484
|
+
Additionally the code generator options can be set (used by the :generator class). The standard generators support the options :buffer and :capture_generator.
|
485
|
+
There are more options which are supported by the filters which are used by `Slim::Engine` but which are not exposed and are not officially supported. You
|
486
|
+
have to take a look at the Slim and Temple code for that.
|
306
487
|
|
307
|
-
|
488
|
+
## Plugins
|
308
489
|
|
309
|
-
|
490
|
+
### Logic-less mode
|
310
491
|
|
311
|
-
|
312
|
-
be a determining factor in your template choice. Even if we don't
|
313
|
-
agree, we'd prefer you to use any other reason for choosing another
|
314
|
-
template language.*
|
492
|
+
Enable the logic-less plugin with
|
315
493
|
|
316
|
-
|
494
|
+
require 'slim/logic_less'
|
495
|
+
|
496
|
+
<table>
|
497
|
+
<thead style="font-weight:bold"><tr><td>Type</td><td>Name</td><td>Default</td><td>Purpose</td></tr></thead>
|
498
|
+
<tbody>
|
499
|
+
<tr><td>Boolean</td><td>:logic_less</td><td>true</td><td>Enable logic less mode (Enabled if 'slim/logic_less' is required)</td></tr>
|
500
|
+
<tr><td>String</td><td>:dictionary</td><td>"self"</td><td>Dictionary where variables are looked up</td></tr>
|
501
|
+
<tr><td>Symbol</td><td>:dictionary_access</td><td>:wrapped</td><td>Dictionary access mode (:string, :symbol, :wrapped)</td></tr>
|
502
|
+
</tbody>
|
503
|
+
</table>
|
504
|
+
|
505
|
+
#### Variable output
|
317
506
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
507
|
+
#### Section
|
508
|
+
|
509
|
+
#### Inverted section
|
510
|
+
|
511
|
+
### Translator
|
512
|
+
|
513
|
+
Enable the translator plugin with
|
514
|
+
|
515
|
+
require 'slim/translator'
|
516
|
+
|
517
|
+
<table>
|
518
|
+
<thead style="font-weight:bold"><tr><td>Type</td><td>Name</td><td>Default</td><td>Purpose</td></tr></thead>
|
519
|
+
<tbody>
|
520
|
+
<tr><td>Boolean</td><td>:tr</td><td>true</td><td>Enable translator (Enabled if 'slim/translator' is required)</td></tr>
|
521
|
+
<tr><td>Symbol</td><td>:tr_mode</td><td>:dynamic</td><td>When to translate: :static = at compile time, :dynamic = at runtime</td></tr>
|
522
|
+
<tr><td>String</td><td>:tr_fn</td><td>Depending on installed translation library</td><td>Translation function, could be '_' for gettext</td></tr>
|
523
|
+
</tbody>
|
524
|
+
</table>
|
525
|
+
|
526
|
+
## Framework support
|
527
|
+
|
528
|
+
### Tilt
|
529
|
+
|
530
|
+
Slim uses Tilt to compile the generated code. If you want to use the Slim template directly, you can use the Tilt interface.
|
531
|
+
|
532
|
+
Tilt.new['template.slim'].render(scope)
|
533
|
+
Slim::Template.new('template.slim', optional_option_hash).render(scope)
|
534
|
+
Slim::Template.new(optional_option_hash) { source }.render(scope)
|
535
|
+
|
536
|
+
The optional option hash can have to options which were documented in the section above.
|
537
|
+
|
538
|
+
### Sinatra
|
539
|
+
|
540
|
+
<pre>
|
541
|
+
require 'sinatra'
|
542
|
+
require 'slim'
|
332
543
|
|
333
|
-
(
|
334
|
-
(3) erubis 0.030000 0.000000 0.030000 ( 0.030705)
|
335
|
-
(3) fast erubis 0.040000 0.000000 0.040000 ( 0.035229)
|
336
|
-
(3) slim 0.040000 0.000000 0.040000 ( 0.036249)
|
337
|
-
(3) haml 0.160000 0.000000 0.160000 ( 0.165024)
|
338
|
-
(3) haml ugly 0.150000 0.000000 0.150000 ( 0.146130)
|
544
|
+
get('/') { slim :index }
|
339
545
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
546
|
+
__END__
|
547
|
+
@@ index
|
548
|
+
doctype html
|
549
|
+
html
|
550
|
+
head
|
551
|
+
title Sinatra With Slim
|
552
|
+
body
|
553
|
+
h1 Slim Is Fun!
|
554
|
+
</pre>
|
555
|
+
|
556
|
+
### Rails
|
557
|
+
|
558
|
+
Rails generators are provided by [slim-rails](https://github.com/leogalmeida/slim-rails). slim-rails
|
559
|
+
is not necessary to use Slim in Rails though. Just install Slim and add it to your Gemfile with `gem 'slim'`.
|
560
|
+
Then just use the .slim extension and you're good to go.
|
345
561
|
|
346
|
-
|
347
|
-
Activate this benchmark with slow=1.
|
562
|
+
## Tools
|
348
563
|
|
349
|
-
|
350
|
-
The ruby code generated by the template engine might be evaluated every time.
|
351
|
-
This benchmark uses the standard API of the template engine.
|
564
|
+
### Syntax Highlighters
|
352
565
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
566
|
+
There are plugins for various text editors (including the most important ones - Vim, Emacs and Textmate):
|
567
|
+
|
568
|
+
* [Vim](https://github.com/bbommarito/vim-slim)
|
569
|
+
* [Emacs](https://github.com/minad/emacs-slim)
|
570
|
+
* [Textmate / Sublime Text](https://github.com/fredwu/ruby-slim-tmbundle)
|
571
|
+
* [Espresso text editor](https://github.com/CiiDub/Slim-Sugar)
|
357
572
|
|
358
|
-
|
359
|
-
accurate result of the performance in production mode in frameworks like
|
360
|
-
Sinatra, Ramaze and Camping. (Rails still uses its own template
|
361
|
-
compilation.)
|
573
|
+
### Template Converters (HAML, ERB, ...)
|
362
574
|
|
363
|
-
|
575
|
+
* [Haml2Slim converter](https://github.com/fredwu/haml2slim)
|
576
|
+
* [HTML2Slim converter](https://github.com/joaomilho/html2slim)
|
577
|
+
* [ERB2Slim converter](https://github.com/c0untd0wn/erb2slim)
|
578
|
+
|
579
|
+
## Testing
|
580
|
+
|
581
|
+
### Benchmarks
|
582
|
+
|
583
|
+
*The benchmarks demonstrate that Slim in production mode
|
584
|
+
is nearly as fast as ERB. So if you choose not to use Slim it
|
585
|
+
is not due to its speed.*
|
586
|
+
|
587
|
+
Run the benchmarks with `rake bench`. You can add the option `slow` to
|
588
|
+
run the slow parsing benchmark which needs more time. You can also increase the number of iterations.
|
589
|
+
|
590
|
+
rake bench slow=1 iterations=1000
|
591
|
+
|
592
|
+
<pre>
|
593
|
+
Linux + Ruby 1.9.3, 1000 iterations
|
594
|
+
user system total real
|
595
|
+
(1) erb 0.020000 0.000000 0.020000 ( 0.016618)
|
596
|
+
(1) erubis 0.010000 0.000000 0.010000 ( 0.013974)
|
597
|
+
(1) fast erubis 0.010000 0.000000 0.010000 ( 0.014625)
|
598
|
+
(1) temple erb 0.030000 0.000000 0.030000 ( 0.024930)
|
599
|
+
(1) slim pretty 0.030000 0.000000 0.030000 ( 0.030838)
|
600
|
+
(1) slim ugly 0.020000 0.000000 0.020000 ( 0.021263)
|
601
|
+
(1) haml pretty 0.120000 0.000000 0.120000 ( 0.121439)
|
602
|
+
(1) haml ugly 0.110000 0.000000 0.110000 ( 0.105082)
|
603
|
+
(2) erb 0.030000 0.000000 0.030000 ( 0.034145)
|
604
|
+
(2) erubis 0.020000 0.000000 0.020000 ( 0.022493)
|
605
|
+
(2) temple erb 0.040000 0.000000 0.040000 ( 0.034921)
|
606
|
+
(2) slim pretty 0.040000 0.000000 0.040000 ( 0.041750)
|
607
|
+
(2) slim ugly 0.030000 0.000000 0.030000 ( 0.030792)
|
608
|
+
(2) haml pretty 0.140000 0.000000 0.140000 ( 0.144159)
|
609
|
+
(2) haml ugly 0.130000 0.000000 0.130000 ( 0.129690)
|
610
|
+
(3) erb 0.140000 0.000000 0.140000 ( 0.140154)
|
611
|
+
(3) erubis 0.110000 0.000000 0.110000 ( 0.110870)
|
612
|
+
(3) fast erubis 0.100000 0.000000 0.100000 ( 0.098940)
|
613
|
+
(3) temple erb 0.040000 0.000000 0.040000 ( 0.036024)
|
614
|
+
(3) slim pretty 0.040000 0.000000 0.040000 ( 0.043326)
|
615
|
+
(3) slim ugly 0.040000 0.000000 0.040000 ( 0.031623)
|
616
|
+
(3) haml pretty 0.310000 0.000000 0.310000 ( 0.317270)
|
617
|
+
(3) haml ugly 0.250000 0.000000 0.250000 ( 0.256257)
|
618
|
+
(4) erb 0.350000 0.000000 0.350000 ( 0.352818)
|
619
|
+
(4) erubis 0.310000 0.000000 0.310000 ( 0.308558)
|
620
|
+
(4) fast erubis 0.310000 0.000000 0.310000 ( 0.308920)
|
621
|
+
(4) temple erb 0.920000 0.000000 0.920000 ( 0.920607)
|
622
|
+
(4) slim pretty 3.510000 0.000000 3.510000 ( 3.513418)
|
623
|
+
(4) slim ugly 2.940000 0.000000 2.940000 ( 2.944823)
|
624
|
+
(4) haml pretty 2.320000 0.000000 2.320000 ( 2.321830)
|
625
|
+
(4) haml ugly 2.180000 0.000000 2.180000 ( 2.179788)
|
626
|
+
|
627
|
+
(1) Compiled benchmark. Template is parsed before the benchmark and
|
628
|
+
generated ruby code is compiled into a method.
|
629
|
+
This is the fastest evaluation strategy because it benchmarks
|
630
|
+
pure execution speed of the generated ruby code.
|
631
|
+
|
632
|
+
(2) Compiled Tilt benchmark. Template is compiled with Tilt, which gives a more
|
633
|
+
accurate result of the performance in production mode in frameworks like
|
634
|
+
Sinatra, Ramaze and Camping. (Rails still uses its own template
|
635
|
+
compilation.)
|
636
|
+
|
637
|
+
(3) Cached benchmark. Template is parsed before the benchmark.
|
638
|
+
The ruby code generated by the template engine might be evaluated every time.
|
639
|
+
This benchmark uses the standard API of the template engine.
|
640
|
+
|
641
|
+
(4) Parsing benchmark. Template is parsed every time.
|
642
|
+
This is not the recommended way to use the template engine
|
643
|
+
and Slim is not optimized for it. Activate this benchmark with 'rake bench slow=1'.
|
644
|
+
|
645
|
+
Temple ERB is the ERB implementation using the Temple framework. It shows the
|
646
|
+
overhead added by the Temple framework compared to ERB.
|
647
|
+
</pre>
|
648
|
+
|
649
|
+
### Test suite and continous integration
|
364
650
|
|
365
651
|
Slim provides an extensive test-suite based on minitest. You can run the tests
|
366
652
|
with 'rake test' and the rails integration tests with 'rake test:rails'.
|
367
653
|
|
368
|
-
Travis-CI is used for continous integration testing: http://travis-ci.org/#!/stonean/slim
|
654
|
+
Travis-CI is used for continous integration testing: {http://travis-ci.org/#!/stonean/slim}
|
369
655
|
|
370
656
|
Slim is working well on all major Ruby implementations:
|
371
657
|
|
@@ -391,24 +677,35 @@ This project is released under the MIT license.
|
|
391
677
|
* [Google Group](http://groups.google.com/group/slim-template)
|
392
678
|
* IRC Channel #slim-lang on freenode.net
|
393
679
|
|
394
|
-
##
|
680
|
+
## Related projects
|
681
|
+
|
682
|
+
Template compilation framework:
|
395
683
|
|
396
684
|
* [Temple](https://github.com/judofyr/slim)
|
397
685
|
|
398
|
-
|
399
|
-
|
400
|
-
* [
|
401
|
-
|
686
|
+
Framework support:
|
687
|
+
|
688
|
+
* [Rails 3 generators (slim-rails)](https://github.com/leogalmeida/slim-rails)
|
689
|
+
|
690
|
+
Syntax highlighting:
|
691
|
+
|
692
|
+
* [Vim](https://github.com/bbommarito/vim-slim)
|
693
|
+
* [Emacs](https://github.com/minad/emacs-slim)
|
694
|
+
* [Textmate / Sublime Text](https://github.com/fredwu/ruby-slim-tmbundle)
|
695
|
+
* [Espresso text editor](https://github.com/CiiDub/Slim-Sugar)
|
696
|
+
|
697
|
+
Template Converters (HAML, ERB, ...):
|
402
698
|
|
403
699
|
* [Haml2Slim converter](https://github.com/fredwu/haml2slim)
|
404
|
-
* [
|
700
|
+
* [HTML2Slim converter](https://github.com/joaomilho/html2slim)
|
701
|
+
* [ERB2Slim converter](https://github.com/c0untd0wn/erb2slim)
|
405
702
|
|
406
|
-
|
703
|
+
Language ports/Similar languages:
|
407
704
|
|
408
705
|
* [Coffee script plugin for Slim](https://github.com/yury/coffee-views)
|
409
|
-
|
410
706
|
* [Clojure port of Slim](https://github.com/chaslemley/slim.clj)
|
411
707
|
* [Hamlet.rb (Similar template language)](https://github.com/gregwebs/hamlet.rb)
|
412
708
|
* [Plim (Python port of Slim)](https://github.com/2nd/plim)
|
413
709
|
* [Skim (Slim for Javascript)](https://github.com/jfirebaugh/skim)
|
414
|
-
|
710
|
+
* [Haml (Older engine which inspired Slim)](https://github.com/nex3/haml)
|
711
|
+
* [Jade (Similar engine for javascript)](https://github.com/visionmedia/jade)
|