Skip to content

Instantly share code, notes, and snippets.

@dlespiau
Created September 13, 2019 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dlespiau/4999e6dd863e2f4bea8b3cff06f4ba43 to your computer and use it in GitHub Desktop.
Save dlespiau/4999e6dd863e2f4bea8b3cff06f4ba43 to your computer and use it in GitHub Desktop.
$ jk run template.js
key: 'value'
count: 42
import * as std from '@jkcfg/std';
import handlebars from 'handlebars/lib/handlebars';
function evaluate(file, context) {
return std.read(file, { encoding: std.Encoding.String }).then(
source => {
const template = handlebars.compile(source);
return template(context);
}
);
}
evaluate('template.yaml', { count: 42 }).then(std.log);
key: 'value'
count: {{count}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment