-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A better way for handle json in templates #10
Comments
I guess it could also support other markup languages like {
transformers: {
'**/*.json.js'(file, stream) {
stream.writeContents(file.path.replace(/\.js$/, ''), transform(file.content))
delete stream.files[file.path]
}
}
} |
Instead of using templates with json try using json/object transformer libs. Check npmjs ;) Here one example: object-transform-stream Many others out there for sure, but perhaps could be done via a general purpose merge template: {
type: 'json',
base {
// baseline object
},
parts: {
author({author}) => author,
repo({username, name}) {
return {
url: `...github/${username}${name}/...`
}
},
// ...
}
} Then merge the result of each generated |
Just implemented this idea using vm2 and it rocks!! |
A json file will become a mess when there're too many conditions like:
Maybe we can use a special extension
.json.js
to generate json file, e.g.template/package.json.js
that will be treat astemplate/package.json
:The text was updated successfully, but these errors were encountered: