segment-boneyard/khaos

How do you change the template delimiter?

Opened this issue · 1 comments

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.

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