Skip to content

Commit

Permalink
fixup: make only "else" in {{else}} the keywords, not "{{else}}" as w…
Browse files Browse the repository at this point in the history
…hole
  • Loading branch information
nknapp committed Jan 31, 2020
1 parent 5ddaa17 commit ec8e1ac
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/languages/handlebars.js
Expand Up @@ -159,8 +159,10 @@ function (hljs) {
contains: [OPENING_BLOCK_MUSTACHE_CONTENTS],
},
{
className: 'keyword',
begin: /\{\{else\}\}/
className: 'template-tag',
begin: /\{\{(?=else\}\})/,
end: /\}\}/,
keywords: 'else'
},
{
// closing block statement
Expand Down
4 changes: 2 additions & 2 deletions test/markup/handlebars/else-variants.expect.txt
@@ -1,8 +1,8 @@
<span class="xml">Multiple possibilities of using "else":

</span><span class="hljs-template-tag">{{#<span class="hljs-name">helper</span>}}</span><span class="hljs-keyword">{{else}}</span><span class="xml">else-block</span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">
</span><span class="hljs-template-tag">{{#<span class="hljs-name">helper</span>}}</span><span class="hljs-template-tag">{{<span class="hljs-keyword">else</span>}}</span><span class="xml">else-block</span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">
...
</span><span class="hljs-template-tag">{{#<span class="hljs-name">helper</span>}}</span><span class="xml">block</span><span class="hljs-keyword">{{else}}</span><span class="xml">else-block</span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">
</span><span class="hljs-template-tag">{{#<span class="hljs-name">helper</span>}}</span><span class="xml">block</span><span class="hljs-template-tag">{{<span class="hljs-keyword">else</span>}}</span><span class="xml">else-block</span><span class="hljs-template-tag">{{/<span class="hljs-name">helper</span>}}</span><span class="xml">
...
</span><span class="hljs-template-variable">{{<span class="hljs-name">[else]</span>}}</span><span class="xml"> in brackets is a helper, not a keyword
...
Expand Down

0 comments on commit ec8e1ac

Please sign in to comment.