bajo-template 1.2.2 → 1.2.4

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 +12 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -50,6 +50,9 @@ async function factory (pkgName) {
50
50
  },
51
51
  _excerpt: (content, words) => {
52
52
  return this.getExcerpt(content, words)
53
+ },
54
+ _dumo: (value, noPre) => {
55
+ return (noPre ? '' : '<pre>') + JSON.stringify(value, null, 2) + (noPre ? '' : '</pre>')
53
56
  }
54
57
  }
55
58
  }
@@ -84,7 +87,7 @@ async function factory (pkgName) {
84
87
 
85
88
  _render = async (tpl, locals = {}, opts = {}) => {
86
89
  this._clearLoopDetector()
87
- const { trim, isEmpty } = this.lib._
90
+ const { trim, isEmpty, last } = this.lib._
88
91
  const { fs } = this.lib
89
92
  const { breakNsPath } = this.app.bajo
90
93
 
@@ -104,7 +107,14 @@ async function factory (pkgName) {
104
107
  this._detectLoop(tpl, file, opts)
105
108
  const fileContent = trim(fs.readFileSync(file, 'utf8'))
106
109
  let { content, frontMatter } = this.splitContent(fileContent)
107
- if (isEmpty(content) && (subNs === 'template')) content = '<!-- include ' + tpl.replace('.template', '.partial') + ' -->'
110
+ if (isEmpty(content)) {
111
+ const sep = '/waibuMpa/route/'
112
+ if (path.isAbsolute(tpl) && tpl.includes(sep)) { // for direct waibuMpa's route
113
+ const parts = tpl.split(sep)
114
+ const ns = last(parts[0].split('/'))
115
+ content = `<!-- include ${ns}.partial:/${parts[1]} -->`
116
+ } else content = '<!-- include ' + tpl.replace('.template', '.partial') + ' -->'
117
+ }
108
118
  opts.ext = path.extname(file)
109
119
  opts.frontMatter = frontMatter
110
120
  opts.partial = opts.partial ?? subNs === 'partial'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo-template",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Template Renderer for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {