From 6af961394cf4bfe8040392c0dd1885df89243e47 Mon Sep 17 00:00:00 2001 From: Nils Knappmeier Date: Mon, 6 Jan 2020 21:36:34 +0100 Subject: [PATCH] wip: {{else}} is a keyword and not a helper call --- src/languages/handlebars.js | 6 +++++- test/markup/handlebars/else-variants.expect.txt | 14 ++++++++++++++ test/markup/handlebars/else-variants.txt | 13 +++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 test/markup/handlebars/else-variants.expect.txt create mode 100644 test/markup/handlebars/else-variants.txt diff --git a/src/languages/handlebars.js b/src/languages/handlebars.js index ef3c363595..83b09fd5b9 100644 --- a/src/languages/handlebars.js +++ b/src/languages/handlebars.js @@ -10,7 +10,7 @@ function (hljs) { var BUILT_INS = { 'builtin-name': 'action bindattr collection component concat debugger ' - + 'each each-in else get hash if in input link-to loc log lookup ' + + 'each each-in get hash if in input link-to loc log lookup ' + 'mut outlet partial query-params render template textarea unbound ' + 'unless view with yield' }; @@ -138,6 +138,10 @@ function (hljs) { begin: /\{\{#/, end: /\}\}/, contains: [OPENING_BLOCK_MUSTACHE_CONTENTS], }, + { + className: 'keyword', + begin: /\{\{else\}\}/ + }, { // closing block statement className: 'template-tag', diff --git a/test/markup/handlebars/else-variants.expect.txt b/test/markup/handlebars/else-variants.expect.txt new file mode 100644 index 0000000000..f157b3e2a5 --- /dev/null +++ b/test/markup/handlebars/else-variants.expect.txt @@ -0,0 +1,14 @@ +Multiple possibilities of using "else": + +{{#helper}}{{else}}else-block{{/helper}} +... +{{#helper}}block{{else}}else-block{{/helper}} +... +{{[else]}} in brackets is a helper, not a keyword +... +{{#else}} as block helper name is not a keyword {{/else}} +... +\{{else}} is not a keyword if escaped +... +Done + diff --git a/test/markup/handlebars/else-variants.txt b/test/markup/handlebars/else-variants.txt new file mode 100644 index 0000000000..d7654bba0e --- /dev/null +++ b/test/markup/handlebars/else-variants.txt @@ -0,0 +1,13 @@ +Multiple possibilities of using "else": + +{{#helper}}{{else}}else-block{{/helper}} +... +{{#helper}}block{{else}}else-block{{/helper}} +... +{{[else]}} in brackets is a helper, not a keyword +... +{{#else}} as block helper name is not a keyword {{/else}} +... +\{{else}} is not a keyword if escaped +... +Done