Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Rendering engine for Express that uses ES6 javascript string templates as syntax.
express-es6-template-engine is an Express-compatible template engine that renders HTML views from ES6 template literal syntax, letting developers use native JavaScript expressions inside backtick-delimited templates without learning a custom template language.
A template engine for Node.js and Express applications that uses pure ES6 JavaScript template strings as its syntax. It scans files in a working directory, reads their contents, converts plain strings to ES6 template strings, and compiles them to text using the V8 engine. The package is under 1kb, has zero dependencies, and requires Node.js version 4.0.0 or higher. It is developed by Dian Dimitrov and released under the MIT License.
The engine requires no new syntax beyond standard ES6 template literals, so any JavaScript developer can start using it immediately.
partials object to res.render, exactly as shown in the partial examples.if expressions and .map() calls inside template literals to render conditionals and loops.Any Express developer who wants to render views without introducing a separate template language will find this engine useful.
app.engine('html', es6Renderer) and render .html files containing ${...} expressions.locals object with variables like title and inject them into templates using ${title} placeholders.partials option.The engine first scans the template files in the configured views directory and reads their contents. It then converts the file content into ES6 template literal strings, which are compiled by the V8 engine into executable JavaScript functions. When rendering, it passes the locals object into the function, evaluates any embedded expressions, and returns the final HTML string through a callback or promise.
No. express-es6-template-engine uses native ES6 template literals, so if you already know JavaScript template strings, you can start rendering views immediately.
Pass a partials object to res.render with keys matching the placeholders in your template and values pointing to the partial file names. The engine injects the rendered partial at render time.
Yes. You can call the engine with a string and a list of variable names to get a compiled function. For example, es6Renderer(text, 'engineName, place') returns a function that you can call with the variable values.
Yes, it is released under the MIT License and can be used freely in commercial and personal projects.
No, template nesting is not currently supported. The documentation suggests performing multiple template compilations and passing the result as a local variable to work around this limitation.
