2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-08 12:06:51 +08:00

Support {{unless}} in virtual dom templates

This commit is contained in:
Robin Ward 2017-10-05 14:34:47 -04:00
parent 7df73c94a0
commit 07d04aba1d
2 changed files with 8 additions and 1 deletions

View file

@ -140,9 +140,13 @@ class Compiler {
} }
break; break;
case "BlockStatement": case "BlockStatement":
let negate = '';
switch(node.path.original) { switch(node.path.original) {
case 'unless':
negate = '!';
case 'if': case 'if':
instructions.push(`if (${node.params[0].original}) {`); instructions.push(`if (${negate}${node.params[0].original}) {`);
node.program.body.forEach(child => { node.program.body.forEach(child => {
instructions = instructions.concat(this.processNode(parentAcc, child)); instructions = instructions.concat(this.processNode(parentAcc, child));
}); });

View file

@ -5,6 +5,9 @@ template = <<~HBS
{{#if state.category}} {{#if state.category}}
{{attach widget="category-display" attrs=(hash category=state.category someNumber=123 someString="wat")}} {{attach widget="category-display" attrs=(hash category=state.category someNumber=123 someString="wat")}}
{{/if}} {{/if}}
{{#unless state.hello}}
XYZ
{{/unless}}
HBS HBS
ctx = MiniRacer::Context.new(timeout: 15000) ctx = MiniRacer::Context.new(timeout: 15000)