Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: handlebars - dot in path names #2172

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/prism-handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
variable: /[\s\S]+/
}
},
'punctuation': /[!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~]/,
'variable': /[^!"#%&'()*+,.\/;<=>@\[\\\]^`{|}~\s]+/
'punctuation': /[!"#%&':()*+,.\/;<=>@\[\\\]^`{|}~]/,
'variable': /[^!"#%&'()*+,\/;<=>@\[\\\]^`{|}~\s]+/
};

Prism.hooks.add('before-tokenize', function(env) {
Expand Down
2 changes: 1 addition & 1 deletion components/prism-handlebars.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 19 additions & 12 deletions tests/languages/handlebars/block_feature.test
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{{#each comments}}{{/each}}
{{~#if isActive~}}{{~/if~}}
{{#let a as |b|}}{{/let}}

----------------------------------------------------

[
["handlebars", [
["delimiter", "{{"], ["block", "#each"], ["variable", "comments"], ["delimiter", "}}"]
]],
["handlebars", [
["delimiter", "{{"], ["block", "/each"], ["delimiter", "}}"]
]],
["handlebars", [
["delimiter", "{{"], ["punctuation", "~"], ["block", "#if"], ["variable", "isActive"], ["punctuation", "~"], ["delimiter", "}}"]
]],
["handlebars", [
["delimiter", "{{"], ["punctuation", "~"], ["block", "/if"], ["punctuation", "~"], ["delimiter", "}}"]
]]
["handlebars",[
["delimiter","{{"],["block","#each"],["variable","comments"],["delimiter","}}"]]
],
["handlebars",[
["delimiter","{{"],["block","/each"],["delimiter","}}"]]
],
["handlebars",[
["delimiter","{{"],["punctuation","~"],["block","#if"],["variable","isActive"],["punctuation","~"],["delimiter","}}"]]
],
["handlebars",[
["delimiter","{{"],["punctuation","~"],["block","/if"],["punctuation","~"],["delimiter","}}"]]
],
["handlebars",[
["delimiter","{{"],["block","#let"],["variable","a"],["variable","as"],["punctuation","|"],["variable","b"],["punctuation","|"],["delimiter","}}"]]
],
["handlebars",[
["delimiter","{{"],["block","/let"],["delimiter","}}"]]
]
]

----------------------------------------------------
Expand Down
273 changes: 273 additions & 0 deletions tests/languages/handlebars/handlebars_in_html_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@
{{aUserModel.name}}
<div>{{listOfUsers.firstObject.name}}</div>
{{if name "I have a name" "I have no name"}}
<span data-has-name={{if name true}}></span>
<div {{on "click" this.hello}} />
----------------------------------------------------

[
[
"handlebars",
[
[
"delimiter",
"{{"
],
[
"variable",
"aUserModel"
],
[
"punctuation",
"."
],
[
"variable",
"name"
],
[
"delimiter",
"}}"
]
]
],
[
"tag",
[
[
"tag",
[
[
"punctuation",
"<"
],
"div"
]
],
[
"punctuation",
">"
]
]
],
[
"handlebars",
[
[
"delimiter",
"{{"
],
[
"variable",
"listOfUsers"
],
[
"punctuation",
"."
],
[
"variable",
"firstObject"
],
[
"punctuation",
"."
],
[
"variable",
"name"
],
[
"delimiter",
"}}"
]
]
],
[
"tag",
[
[
"tag",
[
[
"punctuation",
"</"
],
"div"
]
],
[
"punctuation",
">"
]
]
],
[
"handlebars",
[
[
"delimiter",
"{{"
],
[
"variable",
"if"
],
[
"variable",
"name"
],
[
"string",
"\"I have a name\""
],
[
"string",
"\"I have no name\""
],
[
"delimiter",
"}}"
]
]
],
[
"tag",
[
[
"tag",
[
[
"punctuation",
"<"
],
"span"
]
],
[
"attr-name",
[
"data-has-name"
]
],
[
"attr-value",
[
[
"punctuation",
"="
],
[
"handlebars",
[
[
"delimiter",
"{{"
],
[
"variable",
"if"
],
[
"variable",
"name"
],
[
"boolean",
"true"
],
[
"delimiter",
"}}"
]
]
]
]
],
[
"punctuation",
">"
]
]
],
[
"tag",
[
[
"tag",
[
[
"punctuation",
"</"
],
"span"
]
],
[
"punctuation",
">"
]
]
],
[
"tag",
[
[
"tag",
[
[
"punctuation",
"<"
],
"div"
]
],
[
"attr-name",
[
[
"handlebars",
[
[
"delimiter",
"{{"
],
[
"variable",
"on"
],
[
"string",
"\"click\""
],
[
"variable",
"this"
],
[
"punctuation",
"."
],
[
"variable",
"hello"
],
[
"delimiter",
"}}"
]
]
]
]
],
[
"punctuation",
"/>"
]
]
]
]

----------------------------------------------------

Checks for handlebars filter in Html.
31 changes: 31 additions & 0 deletions tests/languages/handlebars/punctuation_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{~#if isActive~}}{{~/if~}}
{{:slot-name}}
----------------------------------------------------

[
["handlebars", [
["delimiter", "{{"],
["punctuation", "~"],
["block", "#if"],
["variable", "isActive"],
["punctuation", "~"],
["delimiter", "}}"]
]],
["handlebars", [
["delimiter", "{{"],
["punctuation", "~"],
["block", "/if"],
["punctuation", "~"],
["delimiter", "}}"]
]],
["handlebars", [
["delimiter", "{{"],
["punctuation", ":"],
["variable", "slot-name"],
["delimiter", "}}"]
]]
]

----------------------------------------------------

Checks for punctuation.
21 changes: 21 additions & 0 deletions tests/languages/handlebars/variable_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{comments}}
{{@comments}}
{{this.comments}}

----------------------------------------------------

[
["handlebars",[
["delimiter","{{"],["variable","comments"],["delimiter","}}"]]
],
["handlebars",[
["delimiter","{{"],["punctuation","@"],["variable","comments"],["delimiter","}}"]]
],
["handlebars",[
["delimiter","{{"],["variable","this"],["punctuation","."],["variable","comments"],["delimiter","}}"]]
]
]

----------------------------------------------------

Checks for variable.