-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
demo.slim
224 lines (187 loc) · 4.63 KB
/
demo.slim
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
/Comment
/ Space comment
/ Nested Comment
Comment
// Comment
/! HTML comment
/[...] IE comment
/ Root level
section
/ Element with integer
h2
section
#nested
.selectors
/ Classes and IDs
section.class
section.two.classes
section#id
section#id.class
section.class#id
section.class#id.class
section.dash-class
section.dashdash--class
section.underscore_class
section.underscoreunderscore__class
section.-leading-dash
section-with-dashes.class
/ ID and Class Shortcut
.class
.two.classes
#id
#id.class
.class#id
.class#id.class
.dash-class
.dashdash--class
.underscore_class
.underscoreunderscore__class
.-leading-dash
._leading_underscore
/ Attributes
div quoted="attribute"
div quoted="attribute" single='quoted'
div dash-attribute='attribute'
div.class with-attribute="attribute"
div.class with-attribute="attribute\
multiple lines"
div= ruby_var_with_no_space_from_tag
div constant=false
div constant=nil
.foo v-bind:class="{...}"
.foo v-model="name" v-bind:class="{...}"
/ Ruby attributes
div dynamic-value=ruby_variable
/ TODO highlight Ruby variables when they're attribute values
div dynamic-value=ruby_variable(with: args, and: 'strings') text available here for it is Ruby no more
/ Attribute wrapping
div [attibute="this"]
/ TODO should support spaces around attribute name and value
div [ attibute = "this" ] This is text
div(bracket="attributes" multiple="attributes")
div[bracket="attributes" multiple="attributes"]
div [ bracket="attributes" multiple="attributes" ]
/ TODO line-break attribute wrapping doesn't hold
div[bracket="attributes"
multiple="attributes"]
/ Attribute merging
div attribute=['value1', 'value2']
/ TODO highlight attribute merging
div attribute=:value1,value2
/ Splats
#splat*{ 'attribute' => 'value'}
#splat *{attribute: 'value'} Regular text
/ TODO * is incorrectly colored
#splat *@variable
#splat *variable
/ Dynamic tags
*{ tag: 'span' }
/ Interpolation
div #{variable if amount > 0} Extra text
div Extra #{variable if amount > 0} text
div Extra text #{variable if amount > 0}
div attribute="#{variable if amount > 0} extra-text"
/ Whitespace
span< Before
span> attribute="value" After
span.class<> Both
/ Quote
span This is a ' line with a single quote
span.klass This is a ' line with a single 'quote'
span.klass attribute="value" This is a ' line with a single unescaped quote
span.klass Additional code shouldn't be highlighted
span This is a " line with a double quote
span.klass This is a " line with a double "quote"
span.klass attribute="value" This is a " line with a double unescaped quote
span.klass Additional code shouldn"t be highlighted
/ Inline
h2: span Text
h2.with-class.second-class: span Text
h2.with-class.second-class: span.with-class Text
h2: span.class.class Text
h2: span.class attributes="value" Text
.with-class: .single-class data-attribute="value" Text
.with-class.double-class: .class-and.additional.class attrubute="value" Text here
/ XML
loc:url .this is="attr" this is text Title
/ TODO second colon should highlight as a punctuation.definition.tag.end.slim
loc:url: .this is="attr" this is text Title
/ Ruby
p Words with Ruby reserved words like for or in (for)
- array.each do |item|
- if true
- else
== render 'this', locals: { attribute: 'value' }
h1 = yield :yield_sym
= app_helper('string', sym: 'value', class: 'value')
p = app_helper('string', sym: 'value')
- content_for :hello_slim do |this|
p.class
p = @hello
p Regular
/ Without block
- content_for :hello_slim do
p.class
p = @hello
== render 'multiline',
with: 'locals',
and: :symbols
== render 'multiline'\
with: 'locals',
and: :symbols
/ Verbatim
article
| Opening text
Copy line
#{interpolated_ruby / 2}
- if true
| console.log("foo");
- else
| console.log("bar");
div
'Verbatim text with space after
a inline text that's "quoted"
<a href="#">HTML</a>
a href="slim" unhighlighted slim
/ HTML
.inline Text <normal html_underscore_value="value" normal="attribute" html-dash-attribute="value"><and this="this"> Text</normal>
| <tag dash-attribute="this"><tag:with:colon this="this">
<normal class="html-tag" underscore_attribute="value" normal-dash-attribute="value">
/ Embedded Engines
ruby:
blank = []
@instance.each do |item|
blank << item.name
end
# Comment
blank = @instance.map(&:name)
javascript:
(function() {
console.log('hello world');
});
coffee:
anon: ->
console.log 'hello world'
scss:
.hello:before {
color: $world
}
css:
.hello:before {
content: 'world'
}
less:
.hello:before {
content: @world
}
sass:
.hello
content: $world
markdown:
# Hello
**World**
erb:
<%= hello_world if hello_world.present? %>
---
front_matter: present
---