/
syntax.yml
476 lines (318 loc) · 11.9 KB
/
syntax.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
-
title: Tags
docs: |
You can wrap content within an html5 element by just writing the element name at the beginning of a line.
This is supported for all valid html5 tags (list [here](https://developer.mozilla.org/en-US/docs/HTML/HTML5/HTML5_element_list).)
To use a non-html5 tag, just start the line with `%`.
emblem: |
h1 Welcome to Emblem
%blink buy it on Kozmo.com
html: |
<h1>Welcome to Emblem</h1>
<blink>buy it on Kozmo.com</blink>
-
title: Indentation Wrapping
docs: |
To wrap one element in another, just indent and place the element below.
emblem: |
footer
ul
li Hello
li Goodbye
html: |
<footer>
<ul>
<li>Hello</li>
<li>Goodbye</li>
</ul>
</footer>
-
title: CSS Classes
docs: |
CSS classes can added to elements by using a (`.`) with the class name afterwards. You can place this after an element name (`div` is the default tag name).
You can chain multiple class names.
emblem: |
.title Title
h1.logo Law Blog
button.btn.btn-large Submit
html: |
<div class="title">Title</div>
<h1 class="logo">Law Blog</h1>
<button class="btn btn-large">Submit</button>
-
title: IDs
docs: |
Element IDs can be added to elements by using `#` before the element id. Like CSS classes, you can provide an element name (`div` is the default tag name).
emblem: |
#page-content Content
span#name Bob Lablah
html: |
<div id="page-content">Content</div>
<span id="name">Bob Lablah</span>
-
title: HTML Attributes
docs: |
HTML attributes can be added right after the element, using `key="value"` pairs.
HTML attributes can also have mustaches embedded in them, though make sure to use the `unbound` helper in an Ember setting. Note the exclamation mark shorthand for setting an HTML attribute to an unbound property in an Ember setting.
emblem: |
button.close data-dismiss="modal" x
/ For Vanilla Handlebars mode only
button class="large {{foo}}" x
/ For Ember Handlebars
button class="large {{unbound foo}}" x
/ Shorthand for Ember
button class=foo! x
html: |
<button class="close" data-dismiss="modal">x</button>
<button class="large {{foo}}">x</button>
<button class="large {{unbound foo}}">x</button>
<button class="{{unbound foo}}">x</button>
-
title: Comments
docs: |
Start a line with `/` to add a comment. These lines will be ignored completely.
Multiline comments are supported by indenting your comment underneath.
emblem: |
/ Some comment
/ A long long
multiline comment
-
title: Plain Text
docs: |
To output content without an element wrapper, start the line with pipe `|`.
Multiline plaintext content is supported by indenting underneath the tag or `|`.
Plain text can include handlebars output tags `{{}}` and `{{{}}}`. You can also use `#{}` as an alias for `{{}}`.
Block helpers within text blocks can also be used if you're using the `:` colon or `|` pipe syntax.
Use an apostrophe `'` instead of `|` to append a single trailing whitespace at the end of the text block.
emblem: |
| Some content
p
| Lorem #{link-to 'something' | ipsum} dolor sit amet, consectetur
adipisicing elit, sed do eiusmod tempor incididunt ut labore et
dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
span.name Your name is {{name}}
and my name is #{author}
span
' Trailing space
html: |
Some content
<p>
Lorem {{#link-to something}}ipsum{{/link-to}} dolor sit amet,
consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip
ex ea commodo consequat.
</p>
<span class="name">Your name is {{name}} and my name is {{author}}</span>
<span>Trailing space </span>
-
title: Handlebars Expressions
docs: |
To output a handlebars expression, use `=` before expression.
NOTE: You have the option to omit the `=` unless the expression begins with a [known HTML5 tag name](https://developer.mozilla.org/en-US/docs/HTML/HTML5/HTML5_element_list).
emblem: |
h1 = name
p
= intro
= highlight name
html: |
<h1>{{name}}</h1>
<p>
{{intro}}
{{highlight name}}
</p>
-
title: Unescaped Expressions
docs: |
By default Handlebars html escapes output from expressions. To include html without escaping, use `==` which will output Handlebars "triple-stash" expressions `{{{}}}`.
emblem: |
body
== outlet
html: |
<body>
{{{outlet}}}
</body>
-
title: Handlebars Block Helpers
docs: |
Handlebars block statements follow a syntax similar to HTML5 elements, in that indented content on the lines below get wrapped in the block form of the helper.
To use a block helper with the same name as an HTML5 element, you can explicitly use a handlebars block helper by starting the line with `=`.
Block helpers with only text content can be succinctly written on a single line using a `|` pipe to separate the helper code from the text.
emblem: |
ul
each people as |person|
li = person
link-to "home" | Link Text
list nav id="nav-bar" class="top"
a href="url" = title
= strong
= something
if something
p Something!
else
p Something else!
html: |
<ul>
{{#each people as |person|}}
<li>{{person}}</li>
{{/each}}
</ul>
{{#link-to "home"}}
Link Text
{{/link-to}}
{{list nav id="nav-bar" class="top"}}
<a href="{{url}}">{{title}}</a>
{{/list}}
{{#strong}}
{{something}}
{{/strong}}
{{#if something}}
<p>Something!</p>
{{else}}
<p>Something else!</p>
{{/if}}
-
title: Condensed Nesting with Colon Separator
docs: |
You can condense nested HTML or block mustache content into a single line by using `:` to terminate the present element or block mustache declaration.
Whatever comes after a statement-terminating `:` will be interpreted as if it were moved to the line below and indented. This allows you to quickly alternate between nesting HTML elements and mustache blocks on a single line when it makes sense.
This should come in handy for scaffolding frameworks like Twitter Bootstrap (the first part of the example on the right is Bootstrap scaffolding code).
emblem: |
#content-frame: .container: .row
.span4: render "sidebar"
.span8: render "main"
footer: ul.menu-items: each menu_items: li: a.menu-link href=url: link_text
html: |
<div id="content-frame">
<div class="container">
<div class="row">
<div class="span4">
{{render "sidebar"}}
</div>
<div class="span8">
{{render "main"}}
</div>
</div>
</div>
</div>
<footer>
<ul class="menu-items">
{{#each menu_items}}
<li>
<!-- of course, in an Ember.js context, href will be set via a bind-attr -->
<a class="menu-link" href="{{url}}">{{link_text}}</a>
</li>
{{/each}}
</ul>
</footer>
-
title: Views
ember: true
docs: |
Just like in Handlebars, you include an Ember.js view by enclosing the lower-case view name in quotes. Note that input form fields are something of a special case, as the associated view classes are accessed via the "input" helper.
emblem: |
.field
= view "my-custom" someParam="foo"
.field
= view "select" content=options
.field
= input valueBinding="firstName"
html: |
<div class="field">
{{view "my-custom" someParam="foo"}}
</div>
<div class="field">
{{view "select" content=options}}
</div>
<div class="field">
{{input valueBinding="firstName"}}
</div>
-
title: bind-attr Shorthand
ember: true
docs: |
Emblem.js makes binding expression attributes (via `bind-attr`) clean and simple.
emblem: |
img src=logoUrl alt="Logo"
div class=condition:whenTrue:whenFalse
div class={ condition1:whenTrue:whenFalse condition2:whenTrue:whenFalse }
html: |
<img {{bind-attr src="logoUrl"}} alt="Logo">
<div {{bind-attr class="condition:whenTrue:whenFalse"}}></div>
<div {{bind-attr class="condition1:whenTrue:whenFalse condition2:whenTrue:whenFalse"}}></div>
-
title: Action / Events Shorthand
ember: true
docs: |
Like with HTML5 elements, Emblem is aware of common Ember action names, such as `click`, `submit`, `mouseEnter`, etc. When you use these as attributes, they'll be converted to `action` helpers.
If the action helper is a multi-word string, use the contents of that string exactly.
Use single quotes `'` to designate an unbound action.
emblem: |
a click="toggleHeader" x
a click="toggleHeader target='view'" x
a click="toggleHeader this" x
a click="actionWithParam 'fixedParamString'" x
form submit="submitTheForm foo"
p Hello
button click="'unboundAction' item"
html: |
<a {{action toggleHeader on="click"}}>x</a>
<a {{action toggleHeader on="click" target="view"}}>x</a>
<a {{action toggleHeader this on="click"}}>x</a>
<a {{action actionWithParam 'fixedParamString' on="click"}}>x</a>
<form {{action submitTheForm foo on="submit"}}><p>Hello</p></form>
<button {{action 'unboundAction' item on="click"}}></button>
-
title: Explicit Attribute Expressions
ember: true
docs: |
To use expressions within the element attributes (often used in Ember with `bind-attr` and `action`), use the `{}` syntax after the element.
Multiple attribute expressions are also supported.
emblem: |
button{action "delete"} Delete
img{bind-attr src="logoUrl"} alt="logo"
a{bind-attr class="isActive"}{action 'toggleHeader'} x
html: |
<button {{action "delete"}}>Delete</button>
<img {{bind-attr src="logoUrl"}} alt="logo">
<a {{bind-attr class="isActive"}} {{action "toggleHeader"}}>x</a>
-
title: In-Tag Mustache
docs: |
Occasionally, you'll want to put mustache content inside the opening tag of an HTML element. You can do this by immediately following the tag content with curly braces.
Note: instead of using this for Ember's `bind-attr`, you can use Emblem's `bind-attr` syntax described below in Implicit Bind Attributes.
emblem: |
span.some-class{ someHelper } Hello
html: |
<span class="some-class" someHelperOutput="foo">Hello</span>
-
title: Vanilla Handlebars Partials
docs: |
To invoke partials with non-Emberized Handlebars, you can use the `>` syntax.
Note that you'll never really use this for Ember apps; rather, in those cases, you'd use the `partial` helper.
Also note that there's no good way to precompile partials other than to precompile them as templates and then run `Handlebars.partials = Handlebars.templates` before any rendering has taken place.
If you're not precompiling, and you want to directly register an Emblem template, you can use `Emblem.registerPartial`.
emblem: |
> partialName
p Check out this partial: #{> partialName}
> partialName foo
html: |
{{>partialName}}
<p>Check out this partial: {{>partialName}}</p>
{{>partialName foo}}
-
title: Anything wrong or missing here?
docs: |
These docs are [open source](https://github.com/machty/emblem-site), so help us tweak and refine them!
If you're feeling particularly lazy and want to just report an error, [Submit a docs issue](https://github.com/machty/emblem-site/issues/new?title=emblem.js%20plz%20help)
for some clarification on how Emblem.js can be used.
# # Title
# -
# docs: |
# ### Title
# description
# emblem: |
# Emblem
# html: |
# Html result