fastify / point-of-view

Template rendering plugin for Fastify
MIT License
344 stars 87 forks source link

Fixed the use of html-minifier with ejs, added support for local options in the render function #317

Closed TTPO100AJIEX closed 2 years ago

TTPO100AJIEX commented 2 years ago

(I) Fixed the use of html-minifier with ejs. 1) Minification now works in production mode 2) Minification now works when rendering ejs with async set to true

(II) Added support for local options of the render function. 1) Third parameter of .render() can include extra options/overrides for the renderer that are used to compile the template. 2) Local options always override global ones 3) If caching is applied (in production mode) only local options that have been specified for the first rendering of the file are used in template's compilation. Every further request for the same file must have similar options. Dynamic generation of options should be considered undefined behavior and avoided in production mode. 4) If local options are not specified, global are used. 5) Backwards compatibility: should be reserved. Local options do not have effect if not applied; local options are transferred to readCallback as the last parameter which will just always be undefined in old code.

Checklist