Skip to content

Instantly share code, notes, and snippets.

@noahlange
Created October 19, 2017 10:42
Show Gist options
  • Save noahlange/6a3557b86e30b77f95b3ab7e2b224e42 to your computer and use it in GitHub Desktop.
Save noahlange/6a3557b86e30b77f95b3ab7e2b224e42 to your computer and use it in GitHub Desktop.
superjucks compiled template WIP
// sandbox.sjk
// Generated by Superjucks 0.2.0.
export default (() => {
return async (env, frame, ctx, runtime) => {
const lookup = runtime.env.lookup(ctx, frame);
const { Buffer, contains, entries, get } = runtime.env;
const sets = {};
const macros = {};
const blocks = {};
const exports = {};
let parent = null;
// generate macro nodes
macros['in'] = async (foo, bar = 'baz') => {
const buf = new Buffer();
// macro body
return buf.out();
};
// generate block nodes
blocks['if'] = async () => {
const buf = new Buffer();
// block body
return buf.out();
};
// point exports to existing sets/macros/blocks
exports['number'] = macros['in'];
// return render function
const render = async function render() {
ctx.addBlocks(blocks);
ctx.addMacros(macros);
const buf = new Buffer();
// render body
return buf.out();
};
return { render, exports, blocks, macros };
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment