Skip to content

Commit

Permalink
Merge pull request slim-template#841 from thewatts/nw-tailwind
Browse files Browse the repository at this point in the history
Add support for slashes w/ digits and colons in class / id names
  • Loading branch information
andy stone authored Apr 18, 2020
2 parents d7fbf99 + b5e2cda commit 7a32307
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/slim/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def initialize(opts = {})
end
end
keys = Regexp.union @attr_shortcut.keys.sort_by {|k| -k.size }
@attr_shortcut_re = /\A(#{keys}+)((?:\p{Word}|-)*)/
@attr_shortcut_re = /\A(#{keys}+)((?:\p{Word}|-|\/\d+|:(\w|-)+)*)/
keys = Regexp.union @tag_shortcut.keys.sort_by {|k| -k.size }
@tag_re = /\A(?:#{keys}|\*(?=[^\s]+)|(\p{Word}(?:\p{Word}|:|-)*\p{Word}|\p{Word}+))/
keys = Regexp.escape @code_attr_delims.keys.join
Expand Down
10 changes: 9 additions & 1 deletion test/literate/TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1186,13 +1186,15 @@ renders to

#### ID shortcut and class shortcut `.`

ID and class shortcuts can contain dashes.
ID and class shortcuts can contain dashes, slashes with digits, and colons.

~~~ slim
.-test text
#test- text
.--a#b- text
.a--test-123#--b text
.a-1/2#b-1/2 text
.ab:c-test#d:e text
~~~

renders as
Expand All @@ -1210,6 +1212,12 @@ renders as
<div class="a--test-123" id="--b">
text
</div>
<div class="a-1/2" id="b-1/2">
text
</div>
<div class="ab:c-test" id="d:e">
text
</div>
~~~

## Text interpolation
Expand Down

0 comments on commit 7a32307

Please sign in to comment.