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 Apr 10, 2020
1 parent 6a40323 commit a9ebc7b
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
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,10 @@ export default 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
Original file line number Diff line number Diff line change
@@ -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 a9ebc7b

Please sign in to comment.