now supports frontmatter for advanced file templating
This commit is contained in:
@ -69,12 +69,22 @@ export class ScafTemplate {
|
||||
async writeToDisk (destinationDirArg) {
|
||||
let smartfileArrayToWrite = plugins.lodash.cloneDeep(this.templateSmartfileArray)
|
||||
for (let smartfile of smartfileArrayToWrite) {
|
||||
|
||||
// render the template
|
||||
let template = await plugins.smarthbs.getTemplateForString(
|
||||
smartfile.contents.toString()
|
||||
)
|
||||
let renderedTemplateString = template(this.suppliedVariables)
|
||||
smartfile.contents = Buffer.from(renderedTemplateString)
|
||||
|
||||
// handle frontmatter
|
||||
let parsedTemplate = plugins.smartfm.parse(renderedTemplateString)
|
||||
if (parsedTemplate.data.fileName) {
|
||||
smartfile.updateFileName(parsedTemplate.data.fileName)
|
||||
}
|
||||
|
||||
smartfile.contents = Buffer.from(parsedTemplate.content)
|
||||
}
|
||||
|
||||
await plugins.smartfile.memory.smartfileArrayToFs(smartfileArrayToWrite, destinationDirArg)
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ import 'typings-global'
|
||||
import * as lodash from 'lodash'
|
||||
import * as path from 'path'
|
||||
import * as smartfile from 'smartfile'
|
||||
import * as smartfm from 'smartfm'
|
||||
import * as smarthbs from 'smarthbs'
|
||||
import * as smartinteract from 'smartinteract'
|
||||
import * as smartq from 'smartq'
|
||||
@ -11,6 +12,7 @@ export {
|
||||
lodash,
|
||||
path,
|
||||
smartfile,
|
||||
smartfm,
|
||||
smarthbs,
|
||||
smartinteract,
|
||||
smartq,
|
||||
|
Reference in New Issue
Block a user