From a9ebc7b244ed1eba2670c63302465bf0d0857e75 Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Fri, 31 Jan 2020 22:21:24 +0100 Subject: [PATCH] fixup: make only "else" in {{else}} the keywords, not "{{else}}" as whole --- src/languages/handlebars.js | 6 ++++-- test/markup/handlebars/else-variants.expect.txt | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/languages/handlebars.js b/src/languages/handlebars.js index e502113b8f..0936bbbb00 100644 --- a/src/languages/handlebars.js +++ b/src/languages/handlebars.js @@ -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 diff --git a/test/markup/handlebars/else-variants.expect.txt b/test/markup/handlebars/else-variants.expect.txt index ced6f1db06..9169b877c7 100644 --- a/test/markup/handlebars/else-variants.expect.txt +++ b/test/markup/handlebars/else-variants.expect.txt @@ -1,8 +1,8 @@ Multiple possibilities of using "else": -{{#helper}}{{else}}else-block{{/helper}} +{{#helper}}{{else}}else-block{{/helper}} ... -{{#helper}}block{{else}}else-block{{/helper}} +{{#helper}}block{{else}}else-block{{/helper}} ... {{[else]}} in brackets is a helper, not a keyword ...