bajo-template 2.7.0 → 2.9.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.
@@ -1,50 +1,79 @@
1
1
  <!DOCTYPE html><html lang="en" style="font-size:16px"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Source: index.js</title><!--[if lt IE 9]>
2
2
  <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
3
- <![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(locationPathname=document.location.pathname).substr(0,locationPathname.lastIndexOf("/")+1)</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="light"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">BajoTemplate API</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="BajoTemplate.html">BajoTemplate</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#factory">factory</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo-template" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo-template" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section id="source-page" class="source-page"><header><h1 id="title" class="has-anchor">index.js</h1></header><article><pre class="prettyprint source lang-js"><code>import resolveResource, { filecheck } from './lib/resolve-resource.js'
4
- import crypto from 'crypto'
5
- import path from 'path'
3
+ <![endif]--><script src="scripts/third-party/hljs.js" defer="defer"></script><script src="scripts/third-party/hljs-line-num.js" defer="defer"></script><script src="scripts/third-party/popper.js" defer="defer"></script><script src="scripts/third-party/tippy.js" defer="defer"></script><script src="scripts/third-party/tocbot.min.js"></script><script>var baseURL="/",locationPathname="";baseURL=(locationPathname=document.location.pathname).substr(0,locationPathname.lastIndexOf("/")+1)</script><link rel="stylesheet" href="styles/clean-jsdoc-theme.min.css"><svg aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="display:none"><defs><symbol id="copy-icon" viewbox="0 0 488.3 488.3"><g><path d="M314.25,85.4h-227c-21.3,0-38.6,17.3-38.6,38.6v325.7c0,21.3,17.3,38.6,38.6,38.6h227c21.3,0,38.6-17.3,38.6-38.6V124 C352.75,102.7,335.45,85.4,314.25,85.4z M325.75,449.6c0,6.4-5.2,11.6-11.6,11.6h-227c-6.4,0-11.6-5.2-11.6-11.6V124 c0-6.4,5.2-11.6,11.6-11.6h227c6.4,0,11.6,5.2,11.6,11.6V449.6z"/><path d="M401.05,0h-227c-21.3,0-38.6,17.3-38.6,38.6c0,7.5,6,13.5,13.5,13.5s13.5-6,13.5-13.5c0-6.4,5.2-11.6,11.6-11.6h227 c6.4,0,11.6,5.2,11.6,11.6v325.7c0,6.4-5.2,11.6-11.6,11.6c-7.5,0-13.5,6-13.5,13.5s6,13.5,13.5,13.5c21.3,0,38.6-17.3,38.6-38.6 V38.6C439.65,17.3,422.35,0,401.05,0z"/></g></symbol><symbol id="search-icon" viewBox="0 0 512 512"><g><g><path d="M225.474,0C101.151,0,0,101.151,0,225.474c0,124.33,101.151,225.474,225.474,225.474 c124.33,0,225.474-101.144,225.474-225.474C450.948,101.151,349.804,0,225.474,0z M225.474,409.323 c-101.373,0-183.848-82.475-183.848-183.848S124.101,41.626,225.474,41.626s183.848,82.475,183.848,183.848 S326.847,409.323,225.474,409.323z"/></g></g><g><g><path d="M505.902,476.472L386.574,357.144c-8.131-8.131-21.299-8.131-29.43,0c-8.131,8.124-8.131,21.306,0,29.43l119.328,119.328 c4.065,4.065,9.387,6.098,14.715,6.098c5.321,0,10.649-2.033,14.715-6.098C514.033,497.778,514.033,484.596,505.902,476.472z"/></g></g></symbol><symbol id="font-size-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11.246 15H4.754l-2 5H.6L7 4h2l6.4 16h-2.154l-2-5zm-.8-2L8 6.885 5.554 13h4.892zM21 12.535V12h2v8h-2v-.535a4 4 0 1 1 0-6.93zM19 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z"/></symbol><symbol id="add-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M11 11V5h2v6h6v2h-6v6h-2v-6H5v-2z"/></symbol><symbol id="minus-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M5 11h14v2H5z"/></symbol><symbol id="dark-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M10 7a7 7 0 0 0 12 4.9v.1c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2h.1A6.979 6.979 0 0 0 10 7zm-6 5a8 8 0 0 0 15.062 3.762A9 9 0 0 1 8.238 4.938 7.999 7.999 0 0 0 4 12z"/></symbol><symbol id="light-theme-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 18a6 6 0 1 1 0-12 6 6 0 0 1 0 12zm0-2a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM11 1h2v3h-2V1zm0 19h2v3h-2v-3zM3.515 4.929l1.414-1.414L7.05 5.636 5.636 7.05 3.515 4.93zM16.95 18.364l1.414-1.414 2.121 2.121-1.414 1.414-2.121-2.121zm2.121-14.85l1.414 1.415-2.121 2.121-1.414-1.414 2.121-2.121zM5.636 16.95l1.414 1.414-2.121 2.121-1.414-1.414 2.121-2.121zM23 11v2h-3v-2h3zM4 11v2H1v-2h3z"/></symbol><symbol id="reset-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M18.537 19.567A9.961 9.961 0 0 1 12 22C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10c0 2.136-.67 4.116-1.81 5.74L17 12h3a8 8 0 1 0-2.46 5.772l.997 1.795z"/></symbol><symbol id="down-icon" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.7803 6.21967C13.0732 6.51256 13.0732 6.98744 12.7803 7.28033L8.53033 11.5303C8.23744 11.8232 7.76256 11.8232 7.46967 11.5303L3.21967 7.28033C2.92678 6.98744 2.92678 6.51256 3.21967 6.21967C3.51256 5.92678 3.98744 5.92678 4.28033 6.21967L8 9.93934L11.7197 6.21967C12.0126 5.92678 12.4874 5.92678 12.7803 6.21967Z"></path></symbol><symbol id="codepen-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M16.5 13.202L13 15.535v3.596L19.197 15 16.5 13.202zM14.697 12L12 10.202 9.303 12 12 13.798 14.697 12zM20 10.869L18.303 12 20 13.131V10.87zM19.197 9L13 4.869v3.596l3.5 2.333L19.197 9zM7.5 10.798L11 8.465V4.869L4.803 9 7.5 10.798zM4.803 15L11 19.131v-3.596l-3.5-2.333L4.803 15zM4 13.131L5.697 12 4 10.869v2.262zM2 9a1 1 0 0 1 .445-.832l9-6a1 1 0 0 1 1.11 0l9 6A1 1 0 0 1 22 9v6a1 1 0 0 1-.445.832l-9 6a1 1 0 0 1-1.11 0l-9-6A1 1 0 0 1 2 15V9z"/></symbol><symbol id="close-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M12 10.586l4.95-4.95 1.414 1.414-4.95 4.95 4.95 4.95-1.414 1.414-4.95-4.95-4.95 4.95-1.414-1.414 4.95-4.95-4.95-4.95L7.05 5.636z"/></symbol><symbol id="menu-icon" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M3 4h18v2H3V4zm0 7h18v2H3v-2zm0 7h18v2H3v-2z"/></symbol></defs></svg></head><body data-theme="light"><div class="sidebar-container"><div class="sidebar" id="sidebar"><a href="/" class="sidebar-title sidebar-title-anchor">BajoTemplate API</a><div class="sidebar-items-container"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="BajoTemplate.html">BajoTemplate</a></div><div class="sidebar-section-children"><a href="BajoTemplate.html">BajoTemplate</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Imports.html">Imports</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#TImportsResult">TImportsResult</a></div><div class="sidebar-section-children"><a href="global.html#factory">factory</a></div></div></div></div></div><div class="navbar-container" id="VuAckcnZhf"><nav class="navbar"><div class="navbar-left-items"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo-template" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo-template" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="navbar-right-items"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div><nav></nav></nav></div><div class="toc-container"><div class="toc-content"><span class="bold">On this page</span><div id="eed4d2a0bfd64539bb9df78095dec881"></div></div></div><div class="body-wrapper"><div class="main-content"><div class="main-wrapper"><section id="source-page" class="source-page"><header><h1 id="title" class="has-anchor">index.js</h1></header><article><pre class="prettyprint source lang-js"><code>import crypto from 'crypto'
4
+ import _path from 'path'
5
+
6
+ const cache = {}
6
7
 
7
8
  /**
8
- * Plugin factory
9
+ * Plugin factory.
10
+ *
11
+ * **Never** call this function directly!!! It's only-meant to be called by the {@link https://ardhi.github.io/bajo|Bajo framework} during plugin initialization.
9
12
  *
13
+ * @async
10
14
  * @param {string} pkgName - NPM package name
11
- * @returns {class}
15
+ * @returns {Promise&lt;class>} Promise that resolves to the BajoTemplate class
12
16
  */
13
17
  async function factory (pkgName) {
14
18
  const me = this
15
19
 
16
20
  /**
17
- * BajoTemplate class
21
+ * BajoTemplate class definition.
18
22
  *
19
- * @class
23
+ * @class BajoTemplate
20
24
  */
21
- class BajoTemplate extends this.app.pluginClass.base {
22
- static alias = 'tpl'
23
-
25
+ class BajoTemplate extends this.app.baseClass.Base {
26
+ /**
27
+ * Constructor
28
+ */
24
29
  constructor () {
25
30
  super(pkgName, me.app)
31
+ /**
32
+ * @property {object} config - Configuration object
33
+ * @property {object} [config.layout={}] - Layout configuration
34
+ * @property {boolean} [config.layout.fallback=true] - Whether to fallback to default layout if not found
35
+ * @property {Number|string} [config.loopDetectorDur='1m'] - Duration for loop detection
36
+ * @property {object} [config.log={}] - Logging configuration
37
+ * @property {boolean} [config.log.resolver=false] - Whether to log resolver actions
38
+ * @property {object} [config.cache={}] - Cache configuration
39
+ * @property {Number|string} [config.cache.ttlDur='1s'] - Time-to-live duration for cache
40
+ */
26
41
  this.config = {
27
42
  layout: {
28
43
  fallback: true
29
44
  },
30
45
  loopDetectorDur: '1m',
46
+ log: {
47
+ resolver: false
48
+ },
31
49
  cache: {
32
- maxAgeDur: '1s'
50
+ ttlDur: '1s'
33
51
  }
34
52
  }
53
+ /**
54
+ * @property {object} loopDetector - Loop detection object
55
+ */
35
56
  this.loopDetector = {}
36
57
  }
37
58
 
38
- buildCompileImports = (lang) => {
59
+ /**
60
+ * Build compile imports. Used to provide utility functions to templates.
61
+ *
62
+ * @method
63
+ * @param {object} locals - Locals object
64
+ * @param {object} req - Request object
65
+ * @returns {TImportsResult} Imports object
66
+ */
67
+ buildCompileImports = (locals = {}, req = {}) => {
39
68
  const _ = this.app.lib._
40
69
  return {
41
70
  _,
42
71
  _t: (text, ...args) => {
43
- const params = [...args, { lang }]
72
+ const params = [...args, { lang: req.lang }]
44
73
  return this.t(text, ...params)
45
74
  },
46
75
  _format: (val, type, opts = {}) => {
47
- opts.lang = opts.lang ?? lang
76
+ opts.lang = opts.lang ?? req.lang
48
77
  return this.app.bajo.format(val, type, opts)
49
78
  },
50
79
  _findRoute: (input) => {
@@ -67,10 +96,24 @@ async function factory (pkgName) {
67
96
  },
68
97
  _dump: (value, noPre) => {
69
98
  return (noPre ? '' : '&lt;pre>') + JSON.stringify(value, null, 2) + (noPre ? '' : '&lt;/pre>')
99
+ },
100
+ _getSetting: (key, defValue) => {
101
+ if (!this.app.waibu) return _.get(locals, `schema.view.${key}`, defValue)
102
+ const cfg = this.app.waibu.getSetting(key, { defValue, req })
103
+ const { path } = this.app.bajo.breakNsPath(key)
104
+ const paths = path.replaceAll('/', '.').split('.')
105
+ if (paths[0] === '') paths.shift()
106
+ return _.get(locals, `schema.view.${paths.join('.')}`, cfg)
70
107
  }
71
108
  }
72
109
  }
73
110
 
111
+ /**
112
+ * Clear loop detector by removing entries that have expired based on the configured duration.
113
+ *
114
+ * @method
115
+ * @private
116
+ */
74
117
  _clearLoopDetector = () => {
75
118
  const { omit } = this.app.lib._
76
119
  const now = Date.now()
@@ -82,11 +125,20 @@ async function factory (pkgName) {
82
125
  this.loopDetector = omit(this.loopDetector, omitted)
83
126
  }
84
127
 
128
+ /**
129
+ * Detect loop in template rendering.
130
+ *
131
+ * @method
132
+ * @private
133
+ * @param {string} tpl - Template name
134
+ * @param {string} file - File path
135
+ * @param {object} opts - Options object
136
+ */
85
137
  _detectLoop = (tpl, file, opts) => {
86
138
  const { last } = this.app.lib._
87
139
  if (opts.groupId) {
88
140
  if (this.loopDetector[opts.groupId]) {
89
- if (last(this.loopDetector[opts.groupId].file) === file &amp;&amp; path.basename(file)[0] !== '~') {
141
+ if (last(this.loopDetector[opts.groupId].file) === file &amp;&amp; _path.basename(file)[0] !== '~') {
90
142
  throw this.error('loopDetected%s%s', tpl, file)
91
143
  }
92
144
  this.loopDetector[opts.groupId].file.push(file)
@@ -99,6 +151,17 @@ async function factory (pkgName) {
99
151
  }
100
152
  }
101
153
 
154
+ /**
155
+ * Render a template.
156
+ *
157
+ * @async
158
+ * @method
159
+ * @private
160
+ * @param {string} tpl - Template name
161
+ * @param {object} locals - Locals object
162
+ * @param {object} opts - Options object
163
+ * @returns {Promise&lt;string>} Rendered content
164
+ */
102
165
  _render = async (tpl, locals = {}, opts = {}) => {
103
166
  this._clearLoopDetector()
104
167
  const { trim, isEmpty, last } = this.app.lib._
@@ -107,7 +170,7 @@ async function factory (pkgName) {
107
170
 
108
171
  let resp
109
172
  let subNs
110
- if (path.isAbsolute(tpl)) resp = { file: tpl }
173
+ if (_path.isAbsolute(tpl)) resp = { file: tpl }
111
174
  else {
112
175
  subNs = breakNsPath(tpl).subNs
113
176
  if (subNs === 'template') {
@@ -123,25 +186,36 @@ async function factory (pkgName) {
123
186
  let { content, frontMatter } = this.splitContent(fileContent)
124
187
  if (isEmpty(content)) {
125
188
  const sep = '/waibuMpa/route/'
126
- if (path.isAbsolute(tpl) &amp;&amp; tpl.includes(sep)) { // for direct waibuMpa's route
189
+ if (_path.isAbsolute(tpl) &amp;&amp; tpl.includes(sep)) { // for direct waibuMpa's route
127
190
  const parts = tpl.split(sep)
128
191
  const ns = last(parts[0].split('/'))
129
192
  content = `&lt;!-- include ${ns}.partial:/${parts[1]} -->`
130
193
  } else content = '&lt;!-- include ' + tpl.replace('.template', '.partial') + ' -->'
131
194
  }
132
- opts.ext = path.extname(file)
195
+ opts.ext = _path.extname(file)
133
196
  opts.frontMatter = frontMatter
134
197
  opts.partial = opts.partial ?? subNs === 'partial'
135
198
  return await this._renderString(content, locals, opts)
136
199
  }
137
200
 
201
+ /**
202
+ * Handle include directives in the content.
203
+ *
204
+ * @async
205
+ * @method
206
+ * @private
207
+ * @param {string} content - Content string
208
+ * @param {object} locals - Locals object
209
+ * @param {object} opts - Options object
210
+ * @returns {Promise&lt;string>} Processed content
211
+ */
138
212
  _handleInclude = async (content, locals = {}, opts = {}) => {
139
213
  const { isEmpty, omit, template, merge } = this.app.lib._
140
214
  const { extractText } = this.app.lib.aneka
141
215
  const { breakNsPath } = this.app.bajo
142
216
  const start = '&lt;!-- include '
143
217
  const end = ' -->'
144
- const imports = this.buildCompileImports(opts.lang)
218
+ const imports = this.buildCompileImports(locals, opts.req)
145
219
  while (content.includes(start) &amp;&amp; content.includes(end)) {
146
220
  const { pattern, result: rsc } = extractText(content, start, end)
147
221
  if (!isEmpty(rsc)) {
@@ -171,10 +245,21 @@ async function factory (pkgName) {
171
245
  return content
172
246
  }
173
247
 
248
+ /**
249
+ * Render a string with the given locals and options.
250
+ *
251
+ * @async
252
+ * @method
253
+ * @private
254
+ * @param {string} content - Content string
255
+ * @param {object} locals - Locals object
256
+ * @param {object} opts - Options object
257
+ * @returns {Promise&lt;string>} Rendered content
258
+ */
174
259
  _renderString = async (content, locals = {}, opts = {}) => {
175
- const { merge, without, isString, omit, kebabCase } = this.app.lib._
260
+ const { merge, without, isString, omit, kebabCase, get } = this.app.lib._
176
261
  if (opts.ext === '.md' &amp;&amp; this.app.bajoMarkdown) {
177
- content = await this.compile(content, locals, { lang: opts.lang, ttl: -1 }) // markdown can't process template tags, hence preprocess here
262
+ content = await this.compile(content, locals, { ttl: -1, req: opts.req }) // markdown can't process template tags, hence preprocess here
178
263
  content = this.app.bajoMarkdown.parse(content)
179
264
  }
180
265
  let layout
@@ -188,7 +273,7 @@ async function factory (pkgName) {
188
273
  for (const b of ['scriptBlock', 'styleBlock']) {
189
274
  locals.page[b] = pageFm[b] ?? opts[b] ?? (locals.page.ns ? `${locals.page.ns}.partial:/${kebabCase(b)}.html` : `bajoTemplate.partial:/${kebabCase(b)}.html`)
190
275
  }
191
- const ext = path.extname(layout)
276
+ const ext = _path.extname(layout)
192
277
  const { file } = this.resolveLayout(layout, opts)
193
278
  let { content: layoutContent, frontMatter: layoutFm } = this.splitContent(file, true)
194
279
  layoutFm = await this.parseFrontMatter(layoutFm, opts.lang)
@@ -207,27 +292,114 @@ async function factory (pkgName) {
207
292
  }
208
293
  if (layoutFm.title &amp;&amp; !locals.page.title) locals.page.title = layoutFm.title
209
294
  content = layoutContent.replace('&lt;!-- body -->', content)
210
- const appTitle = this.t(locals.page.appTitle, { lang: opts.lang })
211
- const fullTitle = locals.page.title ? `${locals.page.title} - ${appTitle}` : appTitle
212
- locals.page.fullTitle = locals.fullTitle ?? fullTitle
295
+ const usePluginTitle = get(this, 'app.waibuMpa.config.page.usePluginTitle')
296
+ const fullTitle = usePluginTitle ? `${locals.page.title} - ${this.app.waibuMpa.getPluginTitle(locals.page.ns, opts.lang)}` : locals.page.title
297
+ locals.page.fullTitle = locals.page.fullTitle ?? fullTitle
213
298
  }
214
- content = await this.compile(content, locals, { lang: opts.lang, ttl: this.config.cache.maxAgeDur })
299
+ content = await this.compile(content, locals, { ttl: this.config.cache.maxAgeDu, req: opts.req })
215
300
  return await this._handleInclude(content, locals, opts)
216
301
  }
217
302
 
303
+ /**
304
+ * Find a file based on the given options.
305
+ *
306
+ * @method
307
+ * @private
308
+ * @param {object} options - Options object
309
+ * @param {string} options.type - Type of the file
310
+ * @param {string} options.ns - Namespace
311
+ * @param {string} options.subSubNs - Sub-sub namespace
312
+ * @param {string} options.dir - Directory
313
+ * @param {string} options.base - Base name
314
+ * @param {string[]} options.exts - Array of extensions
315
+ * @param {object} options.theme - Theme object
316
+ * @param {object} options.req - Request object
317
+ * @returns {string|null} - Found file path or null
318
+ */
319
+ _findFile = (options = {}) => {
320
+ const { type, ns, subSubNs, dir, base, exts, theme, req } = options
321
+ const checking = ({ check, info }) => {
322
+ const { fs } = this.app.lib
323
+ let file
324
+ for (const ext of exts) {
325
+ let path = `${check}/${dir}/${base}${ext}`
326
+ if (['', '.'].includes(dir)) path = `${check}/${base}${ext}`
327
+ if (fs.existsSync(path)) {
328
+ file = path
329
+ break
330
+ }
331
+ }
332
+ if (this.config.log.resolver) {
333
+ this.log.trace('Checking %s for "%s" -> %s', info, base, check)
334
+ if (file) this.log.trace('OK: %s', file)
335
+ else this.log.trace('Failed')
336
+ }
337
+ return file
338
+ }
339
+
340
+ const extension = subSubNs ? `${subSubNs}/` : ''
341
+ let file
342
+ if (this.app.waibu &amp;&amp; req) {
343
+ const hostname = this.app.waibu.getHostname(req)
344
+ const check = `${this.app.main.dir.pkg}/extend/${this.ns}/${hostname}/${ns}/${extension}${type}`
345
+ file = checking({ check, info: '1. main override: domain specific' })
346
+ }
347
+ if (theme &amp;&amp; !file) {
348
+ const check = `${this.app.main.dir.pkg}/extend/${this.ns}/${theme.name}/${ns}/${extension}${type}`
349
+ file = checking({ check, info: '2. main override: theme specific' })
350
+ }
351
+ if (!file) {
352
+ const check = `${this.app.main.dir.pkg}/extend/${this.ns}/${ns}/${extension}${type}`
353
+ file = checking({ check, info: '3. main override: common' })
354
+ }
355
+ if (theme &amp;&amp; !file) {
356
+ const check = `${theme.plugin.dir.pkg}/extend/${this.ns}/${theme.name}/${ns}/${extension}${type}`
357
+ file = checking({ check, info: '4. override: theme specific' })
358
+ }
359
+ if (theme &amp;&amp; !file) {
360
+ const check = `${theme.plugin.dir.pkg}/extend/${this.ns}/_common/${ns}/${extension}${type}`
361
+ file = checking({ check, info: '5. override: theme specific (common)' })
362
+ }
363
+ if (theme &amp;&amp; !file) {
364
+ const check = `${this.app[ns].dir.pkg}/extend/${this.ns}/${theme.name}/${extension}${type}`
365
+ file = checking({ check, info: '6. real: theme specific' })
366
+ }
367
+ if (!file) {
368
+ const check = `${this.app[ns].dir.pkg}/extend/${this.ns}/${extension}${type}`
369
+ file = checking({ check, info: '7. real: common' })
370
+ }
371
+ return file
372
+ }
373
+
374
+ /**
375
+ * Get a resource by name.
376
+ *
377
+ * @method
378
+ * @param {string} name - Resource name
379
+ * @returns {object} Resource object
380
+ */
218
381
  getResource = (name) => {
219
382
  const subNses = ['layout', 'template', 'partial']
220
383
  const { ns, path, subNs, subSubNs, qs } = this.app.bajo.breakNsPath(name)
221
- const plugin = this.app.bajo.getPlugin(ns)
384
+ const plugin = this.app.getPlugin(ns)
222
385
  const dir = `${plugin.dir.pkg}/extend/bajoTemplate`
223
386
  if (!subNses.includes(subNs)) throw this.error('unknownResource%s', name)
224
387
  const fullPath = subSubNs ? `${dir}/${subSubNs}/${subNs}${path}` : `${dir}/${subNs}${path}`
225
388
  return { ns, subNs, subSubNs, path, qs, fullPath }
226
389
  }
227
390
 
391
+ /**
392
+ * Parse front matter from the input string.
393
+ *
394
+ * @async
395
+ * @method
396
+ * @param {string} input - Input string
397
+ * @param {string} lang - Language
398
+ * @returns {Promise&lt;object>} Parsed front matter
399
+ */
228
400
  parseFrontMatter = async (input = '', lang) => {
229
401
  const { isEmpty, isPlainObject, isArray, filter, map } = this.app.lib._
230
- const { parseObject } = this.app.bajo
402
+ const { parseObject } = this.app.lib
231
403
  const handlers = map(filter(this.app.configHandlers, h => !['.js'].includes(h.ext)), h => h.readHandler)
232
404
  let success
233
405
  for (const handler of handlers) {
@@ -239,103 +411,176 @@ async function factory (pkgName) {
239
411
  }
240
412
  }
241
413
  if (isEmpty(success)) return {}
242
- return parseObject(success, { parseValue: true, lang }) ?? {}
414
+ return parseObject(success, { parseValue: false, lang }) ?? {}
243
415
  }
244
416
 
245
- compile = async (content, locals, { lang, ttl = 0 } = {}) => {
417
+ /**
418
+ * Compile a template with the given content and locals.
419
+ *
420
+ * @async
421
+ * @method
422
+ * @param {string} content - Template content
423
+ * @param {object} locals - Locals object
424
+ * @param {object} options - Options object
425
+ * @param {number} options.ttl - Time to live for cache
426
+ * @param {object} options.req - Request object
427
+ * @returns {Promise&lt;Function>} Compiled template function
428
+ */
429
+ compile = async (content, locals, { ttl = 0, req = {} } = {}) => {
430
+ const { get: getCache, set: setCache } = this.app.bajoCache ?? {}
431
+ const { template } = this.app.lib._
246
432
  locals.attr = locals.attr ?? {}
247
- const _ = this.app.lib._
248
- const { template } = _
249
- const cache = this.app.bajoCache
250
- let canCache = this.config.cache !== false &amp;&amp; cache &amp;&amp; this.app.bajo.config.env !== 'dev'
251
- if (ttl === -1) canCache = false
252
433
  const opts = {
253
- imports: this.buildCompileImports(lang)
434
+ imports: this.buildCompileImports(locals, req)
254
435
  }
255
-
436
+ const key = 'fn:' + crypto.createHash('md5').update(content).digest('hex')
256
437
  let item
257
- if (canCache) {
258
- const key = 'fn:' + crypto.createHash('md5').update(content).digest('hex')
259
- const value = template(content, opts)
260
- item = await cache.sync({ key, value, ttl })
261
- } else {
262
- item = template(content, opts)
438
+ if (getCache) {
439
+ item = await getCache({ key })
440
+ if (item) return item(locals)
263
441
  }
442
+ item = template(content, opts)
443
+ if (setCache) await setCache({ key, value: item, ttl })
264
444
  return item(locals)
265
445
  }
266
446
 
447
+ /**
448
+ * Render a string with the given locals and options.
449
+ *
450
+ * @async
451
+ * @method
452
+ * @param {string} content - Content string
453
+ * @param {object} locals - Locals object
454
+ * @param {object} opts - Options object
455
+ * @returns {Promise&lt;string>} Rendered content
456
+ */
267
457
  renderString = async (content, locals = {}, opts = {}) => {
268
458
  let text = await this._renderString(content, locals, opts)
269
459
  if (opts.postProcessor) text = await opts.postProcessor({ text, locals, opts })
270
460
  return text
271
461
  }
272
462
 
463
+ /**
464
+ * Render a template with the given locals and options.
465
+ *
466
+ * @async
467
+ * @method
468
+ * @param {string} tpl - Template name
469
+ * @param {object} locals - Locals object
470
+ * @param {object} opts - Options object
471
+ * @returns {Promise&lt;string>} Rendered template
472
+ */
273
473
  render = async (tpl, locals = {}, opts = {}) => {
274
474
  const { runHook, breakNsPath } = this.app.bajo
275
475
  const { upperFirst } = this.app.lib._
276
- const cache = this.app.bajoCache
476
+ const { get, set } = this.app.bajoCache ?? {}
277
477
  const key = crypto.createHash('md5').update(`${tpl}:${JSON.stringify(locals)}`).digest('hex')
278
478
  let subNs
279
- const isAbsolute = path.isAbsolute(tpl)
479
+ const isAbsolute = _path.isAbsolute(tpl)
280
480
  if (!isAbsolute) subNs = breakNsPath(tpl).subNs
281
- const canCache = (isAbsolute || subNs === 'template') &amp;&amp; this.config.cache !== false &amp;&amp; cache &amp;&amp; this.app.bajo.config.env !== 'dev'
481
+ const canCache = (isAbsolute || subNs === 'template') &amp;&amp; this.config.cache !== false &amp;&amp; get &amp;&amp; set
282
482
  if (canCache) {
283
- const item = await cache.get({ key })
483
+ const item = await get({ key })
284
484
  if (item) return item
285
485
  }
286
486
  if (subNs) await runHook(`${this.ns}:beforeRender${upperFirst(subNs)}`, { tpl, locals, opts })
287
487
  let text = await this._render(tpl, locals, opts)
288
488
  if (opts.postProcessor) text = await opts.postProcessor({ text, locals, opts })
289
489
  if (subNs) await runHook(`${this.ns}:afterRender${upperFirst(subNs)}`, { tpl, locals, opts, text })
290
- if (canCache) await cache.set({ key, value: text, ttl: opts.cacheMaxAge ?? this.config.cache.maxAgeDur })
490
+ if (canCache) await set({ key, value: text, ttl: opts.ttlDur ?? this.config.cache.ttlDur })
291
491
  return text
292
492
  }
293
493
 
494
+ /**
495
+ * Resolve a resource by type and name.
496
+ *
497
+ * @method
498
+ * @param {string} type - Resource type
499
+ * @param {string} item - Resource name
500
+ * @param {object} opts - Options object
501
+ * @param {Function} fallbackHandler - Fallback handler function
502
+ * @returns {object} Resolved resource
503
+ */
504
+ resolveResource = (type, item = '', opts = {}, fallbackHandler) => {
505
+ const { trim, find, uniq } = this.app.lib._
506
+ const { fs } = this.app.lib
507
+ const env = this.app.bajo.config.env
508
+ if (env !== 'dev' &amp;&amp; cache[item]) return cache[item]
509
+
510
+ let { ns, subSubNs, path } = this.getResource(item)
511
+ const ext = _path.extname(path)
512
+ path = trim(path, '/')
513
+ const dir = _path.dirname(path)
514
+ const base = _path.basename(path, ext)
515
+ const fallbackLang = this.app.bajo.config.intl.fallback
516
+ const exts = uniq([`.${fallbackLang}${ext}`, ext])
517
+ if (opts.lang) exts.unshift(`.${opts.lang}${ext}`)
518
+ let theme
519
+ if (opts.theme &amp;&amp; this.app.waibuMpa &amp;&amp; opts.req) theme = find(this.app.waibuMpa.themes, { name: opts.theme })
520
+ let file = this._findFile({ type, ns, subSubNs, dir, base, exts, theme, req: opts.req })
521
+ if (!file) {
522
+ if (fallbackHandler) file = fallbackHandler.call(this, { dir, base, exts, ns, subSubNs, type, theme, req: opts.req })
523
+ if (opts.default) {
524
+ const fname = this.getResource(opts.default).fullPath
525
+ if (fs.existsSync(fname)) file = fname
526
+ }
527
+ if (!file) throw this.error('cantFind%s%s', type, item)
528
+ }
529
+ const result = { file, ns, layout: opts.layout }
530
+ if (env !== 'dev') cache[item] = result
531
+ return result
532
+ }
533
+
534
+ /**
535
+ * Resolve a layout by name.
536
+ *
537
+ * @method
538
+ * @param {string} item - Layout name
539
+ * @param {object} opts - Options object
540
+ * @returns {object} Resolved layout
541
+ */
294
542
  resolveLayout = (item = '', opts = {}) => {
295
- const { find } = this.app.lib._
296
- const fallbackHandler = ({ file, exts, ns, subSubNs, type, theme }) => {
297
- const dir = ''
298
- const base = 'default'
543
+ const fallbackHandler = ({ type, ns, subSubNs, dir, exts, theme, req }) => {
299
544
  if (!this.config.layout.fallback) return false
300
- // check main: theme specific
301
- if (theme &amp;&amp; !file) {
302
- const check = `${this.app.main.dir.pkg}/extend/${this.ns}/${type}/_${theme}`
303
- file = filecheck.call(this, { dir, base, exts, check })
304
- }
305
- // check main: common
306
- if (!file) {
307
- const check = `${this.app.main.dir.pkg}/extend/${this.ns}/${type}`
308
- file = filecheck.call(this, { dir, base, exts, check })
309
- }
310
- if (theme &amp;&amp; !file) {
311
- const otheme = find(this.app.waibuMpa.themes, { name: theme })
312
- const check = `${otheme.plugin.dir.pkg}/extend/${this.ns}/extend/${this.ns}/${type}`
313
- file = filecheck.call(this, { dir, base, exts, check })
314
- }
315
- // check fallback: common
316
- if (!file) {
317
- const check = `${this.app[ns].dir.pkg}/extend/${this.ns}/${subSubNs ? (subSubNs + '/') : ''}${type}`
318
- file = filecheck.call(this, { dir, base, exts, check })
319
- }
320
- // check general fallback
321
- if (!file) {
322
- const check = `${this.dir.pkg}/extend/${this.ns}/${subSubNs ? (subSubNs + '/') : ''}${type}`
323
- file = filecheck.call(this, { dir, base, exts, check })
324
- }
325
- return file
545
+ const base = 'default'
546
+ return this._findFile({ type, ns, subSubNs, dir, base, exts, theme, req })
326
547
  }
327
548
 
328
- return resolveResource.call(this, 'layout', item, opts, fallbackHandler)
549
+ return this.resolveResource('layout', item, opts, fallbackHandler)
329
550
  }
330
551
 
552
+ /**
553
+ * Resolve a partial by name.
554
+ *
555
+ * @method
556
+ * @param {string} item - Partial name
557
+ * @param {object} opts - Options object
558
+ * @returns {object} Resolved partial
559
+ */
331
560
  resolvePartial = (item = '', opts = {}) => {
332
- return resolveResource.call(this, 'partial', item, opts)
561
+ return this.resolveResource('partial', item, opts)
333
562
  }
334
563
 
564
+ /**
565
+ * Resolve a template by name.
566
+ *
567
+ * @method
568
+ * @param {string} item - Template name
569
+ * @param {object} opts - Options object
570
+ * @returns {object} Resolved template
571
+ */
335
572
  resolveTemplate = (item = '', opts = {}) => {
336
- return resolveResource.call(this, 'template', item, opts)
573
+ return this.resolveResource('template', item, opts)
337
574
  }
338
575
 
576
+ /**
577
+ * Split content into front matter and body.
578
+ *
579
+ * @method
580
+ * @param {string} input - Input string or file path
581
+ * @param {boolean} readFile - Whether to read the file
582
+ * @returns {object} Object containing frontMatter and content
583
+ */
339
584
  splitContent = (input, readFile) => {
340
585
  const { fs } = this.app.lib
341
586
  const start = '---\n'
@@ -358,13 +603,35 @@ async function factory (pkgName) {
358
603
  return { frontMatter, content }
359
604
  }
360
605
 
361
- // based on: https://medium.com/@paulohfev/problem-solving-how-to-create-an-excerpt-fdb048687928
362
- getExcerpt = (content, maxWords = 50, trailChars = '...') => {
606
+ /**
607
+ * Get an excerpt from the content.
608
+ *
609
+ * @method
610
+ * @param {string} content - Content string
611
+ * @param {number} maxWords - Maximum number of words
612
+ * @param {string} trailChars - Trailing characters
613
+ * @returns {string} Excerpt
614
+ * @see {@link https://medium.com/@paulohfev/problem-solving-how-to-create-an-excerpt-fdb048687928|Problem Solving: How to Create an Excerpt}
615
+ */
616
+ getExcerpt = (content = '', maxWords = 50, trailChars = '...') => {
363
617
  const listOfWords = content.trim().split(' ')
364
618
  const truncatedContent = listOfWords.slice(0, maxWords).join(' ')
365
619
  const excerpt = truncatedContent + trailChars
366
- const output = listOfWords.length > maxWords ? excerpt : content
367
- return output
620
+ return listOfWords.length > maxWords ? excerpt : content
621
+ }
622
+
623
+ /**
624
+ * Get a truncated version of the content.
625
+ *
626
+ * @method
627
+ * @param {string} content - Content string
628
+ * @param {number} maxChars - Maximum number of characters
629
+ * @param {string} trailChars - Trailing characters
630
+ * @returns {string} Truncated content
631
+ */
632
+ getTruncated = (content = '', maxChars = 50, trailChars = '...') => {
633
+ const truncated = content.slice(0, maxChars)
634
+ return truncated.length !== content.length ? (truncated + trailChars) : content
368
635
  }
369
636
  }
370
637
 
@@ -372,4 +639,4 @@ async function factory (pkgName) {
372
639
  }
373
640
 
374
641
  export default factory
375
- </code></pre></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">BajoTemplate API</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo-template" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo-template" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="BajoTemplate.html">BajoTemplate</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#factory">factory</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>
642
+ </code></pre></article></section></div></div></div><div class="search-container" id="PkfLWpAbet" style="display:none"><div class="wrapper" id="iCxFxjkHbP"><button class="icon-button search-close-button" id="VjLlGakifb" aria-label="close search"><svg><use xlink:href="#close-icon"></use></svg></button><div class="search-box-c"><svg><use xlink:href="#search-icon"></use></svg> <input type="text" id="vpcKVYIppa" class="search-input" placeholder="Search..." autofocus></div><div class="search-result-c" id="fWwVHRuDuN"><span class="search-result-c-text">Type anything to view search result</span></div></div></div><div class="mobile-menu-icon-container"><button class="icon-button" id="mobile-menu" data-isopen="false" aria-label="menu"><svg><use xlink:href="#menu-icon"></use></svg></button></div><div id="mobile-sidebar" class="mobile-sidebar-container"><div class="mobile-sidebar-wrapper"><a href="/" class="sidebar-title sidebar-title-anchor">BajoTemplate API</a><div class="mobile-nav-links"><div class="navbar-item"><a id="" href="https://www.npmjs.com/package/bajo-template" target="">NPM</a></div><div class="navbar-item"><a id="" href="https://github.com/ardhi/bajo-template" target="">Github</a></div><div class="navbar-item"><a id="" href="https://bajo.app" target="">Bajo</a></div></div><div class="mobile-sidebar-items-c"><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-classes"><div>Classes</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="BajoTemplate.html">BajoTemplate</a></div><div class="sidebar-section-children"><a href="BajoTemplate.html">BajoTemplate</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-modules"><div>Modules</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="module-Imports.html">Imports</a></div></div><div class="sidebar-section-title with-arrow" data-isopen="false" id="sidebar-global"><div>Global</div><svg><use xlink:href="#down-icon"></use></svg></div><div class="sidebar-section-children-container"><div class="sidebar-section-children"><a href="global.html#TImportsResult">TImportsResult</a></div><div class="sidebar-section-children"><a href="global.html#factory">factory</a></div></div></div><div class="mobile-navbar-actions"><div class="navbar-right-item"><button class="icon-button search-button" aria-label="open-search"><svg><use xlink:href="#search-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button theme-toggle" aria-label="toggle-theme"><svg><use class="theme-svg-use" xlink:href="#dark-theme-icon"></use></svg></button></div><div class="navbar-right-item"><button class="icon-button font-size" aria-label="change-font-size"><svg><use xlink:href="#font-size-icon"></use></svg></button></div></div></div></div><script type="text/javascript" src="scripts/core.min.js"></script><script src="scripts/search.min.js" defer="defer"></script><script src="scripts/third-party/fuse.js" defer="defer"></script><script type="text/javascript">var tocbotInstance=tocbot.init({tocSelector:"#eed4d2a0bfd64539bb9df78095dec881",contentSelector:".main-content",headingSelector:"h1, h2, h3",hasInnerContainers:!0,scrollContainer:".main-content",headingsOffset:130,onClick:bringLinkToView})</script></body></html>