ventojs 0.12.1 → 0.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,7 +12,9 @@ function layoutTag(env, code, output, tokens) {
12
12
  throw new Error(`Invalid wrap: ${code}`);
13
13
  }
14
14
  const [_, file, data] = match;
15
- const varname = "__content";
15
+ const varname = output.startsWith("__layout")
16
+ ? output + "_layout"
17
+ : "__layout";
16
18
  const compiled = [];
17
19
  const compiledFilters = env.compileFilters(tokens, varname);
18
20
  compiled.push("{");
@@ -17,12 +17,9 @@ function setTag(env, code, _output, tokens) {
17
17
  }
18
18
  const [, variable, value] = match;
19
19
  const val = env.compileFilters(tokens, value);
20
- return `if (${dataVarname}.hasOwnProperty("${variable}")) {
21
- ${variable} = ${val};
22
- } else {
23
- var ${variable} = ${val};
24
- }
25
- ${dataVarname}["${variable}"] = ${variable};
20
+ return `
21
+ ${dataVarname}["${variable}"] = ${val};
22
+ var ${variable} = ${val};
26
23
  `;
27
24
  }
28
25
  // Value is captured (eg: {{ set foo }}bar{{ /set }})
@@ -100,7 +100,9 @@ export class Environment {
100
100
  continue;
101
101
  }
102
102
  if (type === "string") {
103
- compiled.push(`${outputVar} += ${JSON.stringify(code)};`);
103
+ if (code !== "") {
104
+ compiled.push(`${outputVar} += ${JSON.stringify(code)};`);
105
+ }
104
106
  continue;
105
107
  }
106
108
  if (type === "tag") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ventojs",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "description": "🌬 A minimal but powerful template engine",
5
5
  "homepage": "https://vento.js.org/",
6
6
  "repository": "github:oscarotero/vento",