You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
576 B
22 lines
576 B
const fs = require('fs')
|
|
const path = require('path')
|
|
const parse = require('./template-transformer/parser')
|
|
|
|
function getTemplate (content) {
|
|
const template = []
|
|
const node = parse(content)
|
|
node.children.forEach(node => {
|
|
if (node.name === 'template') {
|
|
const name = node.attribs.name
|
|
if (name) {
|
|
template.push(name)
|
|
}
|
|
}
|
|
})
|
|
return template
|
|
}
|
|
|
|
module.exports = function (filepath, options) {
|
|
filepath = path.join(path.dirname(options.filepath), filepath)
|
|
return getTemplate(fs.readFileSync(filepath, 'utf8').toString().trim())
|
|
} |