boxwood 0.67.0 → 0.68.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 +20 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -474,8 +474,28 @@ i18n.load = function () {
474
474
  }
475
475
  }
476
476
 
477
+ function component(fn, styles) {
478
+ function execute(a, b) {
479
+ if (typeof a === "string" || Array.isArray(a)) {
480
+ return fn({}, a)
481
+ }
482
+ return fn(a, b || [])
483
+ }
484
+ return function (a, b) {
485
+ const tree = execute(a, b)
486
+ if (styles) {
487
+ if (Array.isArray(tree)) {
488
+ return tree.concat(styles.css)
489
+ }
490
+ return [tree, styles.css]
491
+ }
492
+ return tree
493
+ }
494
+ }
495
+
477
496
  module.exports = {
478
497
  compile,
498
+ component,
479
499
  classes,
480
500
  doctype,
481
501
  escape: escapeHTML,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boxwood",
3
- "version": "0.67.0",
3
+ "version": "0.68.0",
4
4
  "description": "Compile HTML templates into JS",
5
5
  "main": "index.js",
6
6
  "scripts": {