boxwood 0.69.1 → 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 -16
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -230,27 +230,21 @@ raw.load = function () {
230
230
  }
231
231
 
232
232
  const tag = (a, b, c) => {
233
- if (a && b && c) {
233
+ if (typeof b === "string" || typeof b === "number" || Array.isArray(b)) {
234
234
  const name = a
235
- const attributes = b
236
- const children = c
235
+ const children = b
237
236
  return {
238
237
  name,
239
- children,
240
- attributes,
238
+ children: children,
241
239
  }
242
240
  }
243
241
  const name = a
244
- const children = b
245
- if (SELF_CLOSING_TAGS.includes(name)) {
246
- return {
247
- name,
248
- attributes: children,
249
- }
250
- }
242
+ const attributes = b
243
+ const children = c || []
251
244
  return {
252
245
  name,
253
246
  children,
247
+ attributes,
254
248
  }
255
249
  }
256
250
 
@@ -285,7 +279,8 @@ function css(inputs) {
285
279
 
286
280
  css.load = function () {
287
281
  const path = join(...arguments)
288
- const content = readFileSync(path, "utf8")
282
+ const file = path.endsWith(".css") ? path : join(path, "index.css")
283
+ const content = readFileSync(file, "utf8")
289
284
  return css`
290
285
  ${content}
291
286
  `
@@ -309,7 +304,8 @@ function js(inputs) {
309
304
 
310
305
  js.load = function () {
311
306
  const path = join(...arguments)
312
- const content = readFileSync(path, "utf8")
307
+ const file = path.endsWith(".js") ? path : join(path, "index.js")
308
+ const content = readFileSync(file, "utf8")
313
309
  return js`${content}`
314
310
  }
315
311
 
@@ -456,6 +452,7 @@ function classes() {
456
452
  const yaml = {
457
453
  load() {
458
454
  const path = join(...arguments)
455
+ const file = path.endsWith(".yaml") ? path : join(path, "index.yaml")
459
456
  const content = readFileSync(path, "utf8")
460
457
  return YAML.parse(content)
461
458
  },
@@ -464,7 +461,8 @@ const yaml = {
464
461
  const json = {
465
462
  load() {
466
463
  const path = join(...arguments)
467
- const content = readFileSync(path, "utf8")
464
+ const file = path.endsWith(".json") ? path : join(path, "index.json")
465
+ const content = readFileSync(file, "utf8")
468
466
  return JSON.parse(content)
469
467
  },
470
468
  }
@@ -485,7 +483,7 @@ i18n.load = function () {
485
483
 
486
484
  function component(fn, { styles, i18n } = {}) {
487
485
  function execute(a, b) {
488
- if (typeof a === "string" || Array.isArray(a)) {
486
+ if (typeof a === "string" || typeof a === "number" || Array.isArray(a)) {
489
487
  return fn({}, a)
490
488
  }
491
489
  if (i18n) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.69.1",
3
+ "version": "0.70.0",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {