Created
October 19, 2017 10:42
-
-
Save noahlange/6a3557b86e30b77f95b3ab7e2b224e42 to your computer and use it in GitHub Desktop.
superjucks compiled template WIP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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