boxwood 0.72.0 → 0.73.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 +16 -1
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -438,6 +438,9 @@ function extension(path) {
438
438
 
439
439
  function media(path) {
440
440
  const type = extension(path)
441
+ if (type === "svg") {
442
+ return "image/svg+xml"
443
+ }
441
444
  return `image/${type === "jpg" ? "jpeg" : type}`
442
445
  }
443
446
 
@@ -528,7 +531,7 @@ i18n.load = function () {
528
531
  }
529
532
  }
530
533
 
531
- function component(fn, { styles, i18n } = {}) {
534
+ function component(fn, { styles, i18n, code } = {}) {
532
535
  function execute(a, b) {
533
536
  if (typeof a === "string" || typeof a === "number" || Array.isArray(a)) {
534
537
  return fn({}, a)
@@ -560,12 +563,24 @@ function component(fn, { styles, i18n } = {}) {
560
563
  }
561
564
  return function (a, b) {
562
565
  const tree = execute(a, b)
566
+ if (styles && code) {
567
+ if (Array.isArray(tree)) {
568
+ return tree.concat(styles.css, code.js)
569
+ }
570
+ return [tree, styles.css, code.js]
571
+ }
563
572
  if (styles) {
564
573
  if (Array.isArray(tree)) {
565
574
  return tree.concat(styles.css)
566
575
  }
567
576
  return [tree, styles.css]
568
577
  }
578
+ if (code) {
579
+ if (Array.isArray(tree)) {
580
+ return tree.concat(code.js)
581
+ }
582
+ return [tree, code.js]
583
+ }
569
584
  return tree
570
585
  }
571
586
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.72.0",
3
+ "version": "0.73.0",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,11 +45,11 @@
45
45
  },
46
46
  "homepage": "https://github.com/buxlabs/boxwood#readme",
47
47
  "devDependencies": {
48
- "ava": "^5.2.0",
48
+ "ava": "^5.3.1",
49
49
  "benchmark": "2.1.4",
50
50
  "express": "^4.18.2",
51
- "handlebars": "^4.7.7",
52
- "jsdom": "^21.1.0",
51
+ "handlebars": "^4.7.8",
52
+ "jsdom": "^22.1.0",
53
53
  "lodash.template": "4.5.0",
54
54
  "mustache": "^4.2.0",
55
55
  "nyc": "15.1.0",
@@ -65,6 +65,6 @@
65
65
  "dependencies": {
66
66
  "css-tree": "^2.3.1",
67
67
  "string-hash": "^1.1.3",
68
- "yaml": "^2.2.1"
68
+ "yaml": "^2.3.2"
69
69
  }
70
70
  }