4 ms·
I've been doing something very similar for templating static HTML sites amongst other things - you can interpret any string as a JS template string: functi
by err4nt 7y ago
I've been doing something very similar for templating static HTML sites amongst other things - you can interpret any string as a JS template string:
function jstsEngine(string = '', environment = {}) {
return new Function(
...Object.keys(environment),
'output={}',
'return [`' + string + '`, output]'
)(...Object.values(environment))
}
Link with examples: https://github.com/tomhodgins/jsts-engine https://github.com/tomhodgins/jsts-engine
- errantspark 7y agoThat's what I'm using it for as well! I believe our functions here are isomorphic, though I'm a couple lines shorter ;) You've got an excellent username btw. <3
- err4nt 7y ago<3 you have a nice username too :D