Simple dynamic templating in JS
Simple dynamic templating in JS
How do you guys deal with this scenario? const renderTemplate = (template, obj) => { const args = Object.keys(obj) const body = `return (\`${template}\`)` const renderFunc = new Function(...args.concat([body])) return renderFunc(...Object.values(obj)) } const dynamicallyLoadedTemplate = '${a} and ${b}' console.log( renderTemplate(dynamicallyLoadedTemplate, { 'a': '1', 'b': 2 }) ) Is this elegant enough?
Share cardActual performance
Launch Intel predictions
Analyze your own launch →Correct prediction on native model
Similar products
Simon, a simple approach to dynamic hosts with Redis + Lua + Nginx
Honeycomb-js – An implementation of a simple kaleidoscope
A simple, module-system-agnostic chainable comparators JS lib
Next.js made simple
A simple tool for exploring AdSense with D3.js
Multithread.js – In-browser multithreading made simple
A Simple Game Made with Three.js
Dynamic schemas for golang protobufs
ddgrey – dynamic and optionally distributed greylisting daemon
Screencast on Meteor Dynamic Scoping