boxwood 0.69.0 → 0.70.0

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.
Files changed (2) hide show
  1. package/index.js +14 -20
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -5,10 +5,6 @@ const toHash = require("string-hash")
5
5
  const YAML = require("yaml")
6
6
 
7
7
  async function compile(path) {
8
- if (process.env.NODE_ENV === "development") {
9
- const name = require.resolve(path)
10
- delete require.cache[name]
11
- }
12
8
  const fn = require(path)
13
9
  return {
14
10
  template() {
@@ -234,27 +230,21 @@ raw.load = function () {
234
230
  }
235
231
 
236
232
  const tag = (a, b, c) => {
237
- if (a && b && c) {
233
+ if (typeof b === "string" || typeof b === "number" || Array.isArray(b)) {
238
234
  const name = a
239
- const attributes = b
240
- const children = c
235
+ const children = b
241
236
  return {
242
237
  name,
243
- children,
244
- attributes,
238
+ children: children,
245
239
  }
246
240
  }
247
241
  const name = a
248
- const children = b
249
- if (SELF_CLOSING_TAGS.includes(name)) {
250
- return {
251
- name,
252
- attributes: children,
253
- }
254
- }
242
+ const attributes = b
243
+ const children = c || []
255
244
  return {
256
245
  name,
257
246
  children,
247
+ attributes,
258
248
  }
259
249
  }
260
250
 
@@ -289,7 +279,8 @@ function css(inputs) {
289
279
 
290
280
  css.load = function () {
291
281
  const path = join(...arguments)
292
- const content = readFileSync(path, "utf8")
282
+ const file = path.endsWith(".css") ? path : join(path, "index.css")
283
+ const content = readFileSync(file, "utf8")
293
284
  return css`
294
285
  ${content}
295
286
  `
@@ -313,7 +304,8 @@ function js(inputs) {
313
304
 
314
305
  js.load = function () {
315
306
  const path = join(...arguments)
316
- const content = readFileSync(path, "utf8")
307
+ const file = path.endsWith(".js") ? path : join(path, "index.js")
308
+ const content = readFileSync(file, "utf8")
317
309
  return js`${content}`
318
310
  }
319
311
 
@@ -460,6 +452,7 @@ function classes() {
460
452
  const yaml = {
461
453
  load() {
462
454
  const path = join(...arguments)
455
+ const file = path.endsWith(".yaml") ? path : join(path, "index.yaml")
463
456
  const content = readFileSync(path, "utf8")
464
457
  return YAML.parse(content)
465
458
  },
@@ -468,7 +461,8 @@ const yaml = {
468
461
  const json = {
469
462
  load() {
470
463
  const path = join(...arguments)
471
- const content = readFileSync(path, "utf8")
464
+ const file = path.endsWith(".json") ? path : join(path, "index.json")
465
+ const content = readFileSync(file, "utf8")
472
466
  return JSON.parse(content)
473
467
  },
474
468
  }
@@ -489,7 +483,7 @@ i18n.load = function () {
489
483
 
490
484
  function component(fn, { styles, i18n } = {}) {
491
485
  function execute(a, b) {
492
- if (typeof a === "string" || Array.isArray(a)) {
486
+ if (typeof a === "string" || typeof a === "number" || Array.isArray(a)) {
493
487
  return fn({}, a)
494
488
  }
495
489
  if (i18n) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.69.0",
3
+ "version": "0.70.0",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {