bajo-template 1.2.3 → 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 +9 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -87,7 +87,7 @@ async function factory (pkgName) {
87
87
 
88
88
  _render = async (tpl, locals = {}, opts = {}) => {
89
89
  this._clearLoopDetector()
90
- const { trim, isEmpty } = this.lib._
90
+ const { trim, isEmpty, last } = this.lib._
91
91
  const { fs } = this.lib
92
92
  const { breakNsPath } = this.app.bajo
93
93
 
@@ -107,7 +107,14 @@ async function factory (pkgName) {
107
107
  this._detectLoop(tpl, file, opts)
108
108
  const fileContent = trim(fs.readFileSync(file, 'utf8'))
109
109
  let { content, frontMatter } = this.splitContent(fileContent)
110
- 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
+ }
111
118
  opts.ext = path.extname(file)
112
119
  opts.frontMatter = frontMatter
113
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.3",
3
+ "version": "1.2.4",
4
4
  "description": "Template Renderer for Bajo Framework",
5
5
  "main": "index.js",
6
6
  "scripts": {