lit-nunjucks
Advanced tools
Comparing version
@@ -297,5 +297,8 @@ const nunjucks = require("nunjucks"); | ||
node.val instanceof n.Literal | ||
? t.identifier(node.val.value) | ||
? Number.isInteger(node.val.value) | ||
? t.numericLiteral(node.val.value) | ||
: t.identifier(node.val.value) | ||
: this.wrap(node.val), | ||
!(node.val instanceof n.Literal) | ||
!(node.val instanceof n.Literal) || | ||
Number.isInteger(node.val.value) | ||
); | ||
@@ -302,0 +305,0 @@ } |
{ | ||
"name": "lit-nunjucks", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Nunjucks compiler to lit-html", | ||
@@ -5,0 +5,0 @@ "main": "lit-nunjucks.js", |
@@ -174,2 +174,10 @@ const { compile } = require("../lit-nunjucks"); | ||
}); | ||
test("should read nested properties or arrays", () => { | ||
expect(compile(`{{a.selling_plan.options[0].value}}`)).toEqual( | ||
toCode("{return a.selling_plan.options[0].value;}", "a") | ||
); | ||
expect(compile(`{{a[0].value}}`)).toEqual( | ||
toCode("{return a[0].value;}", "a") | ||
); | ||
}); | ||
test("should binary operators", () => { | ||
@@ -248,9 +256,10 @@ expect(compile(`{{ a and 1}}`)).toEqual( | ||
}); | ||
describe("literals", () => { | ||
it("should support true/false", () => { | ||
expect(compile(" {% set foo = true %} ")).toEqual( | ||
toCode("{var foo; return html` ${(()=>{foo=true;})()} `;}","") | ||
toCode("{var foo; return html` ${(()=>{foo=true;})()} `;}", "") | ||
); | ||
expect(compile(" {% set foo = false %} ")).toEqual( | ||
toCode("{var foo; return html` ${(()=>{foo=false;})()} `;}","") | ||
toCode("{var foo; return html` ${(()=>{foo=false;})()} `;}", "") | ||
); | ||
@@ -260,3 +269,3 @@ }); | ||
expect(compile(" {% set foo = null %} ")).toEqual( | ||
toCode("{var foo; return html` ${(()=>{foo=null;})()} `;}","") | ||
toCode("{var foo; return html` ${(()=>{foo=null;})()} `;}", "") | ||
); | ||
@@ -263,0 +272,0 @@ }); |
28512
1.81%733
1.52%