segment-boneyard / khaos

A super-simple way to scaffold new projects.
http://khaos.io
407 stars 46 forks source link

How do you change the template delimiter? #103

Open pajtai opened 7 years ago

pajtai commented 7 years ago

How do you change the delimiters from {{, }} to something else? I'd like to use khaos for a vuejs project, but vuejs uses {{, }}.

I looked in the docs, and I did a text search for delimiter via the github search with no results.

kennethlynne commented 6 years ago

If this project used lodash templates instead of handlebars it would be pretty straight forward I think.

https://lodash.com/docs/4.17.4#template

Just replace this line https://github.com/segmentio/khaos/blob/aaff401a1915c319fa906fdcc401c870a47b02dc/lib/plugins/write.js#L34 with

_.templateSettings.interpolate = /{{([\s\S]+?)}}/g;
var fn = _.template(file);

We also need this since we want to generate templates with templates (https://github.com/kubernetes/helm/blob/master/docs/examples/nginx/templates/service-test.yaml) and coincidentally those templates already use the same delimiter