Closed doowb closed 9 years ago
This makes it so users that want to modify something else in a postRender middleware can't because the changes only affect the cloned object and are lost.
What are the common use cases for passing the cloned.content
back to the caller? Either way I think we should ensure that middleware can modify properties post render.
Passing the cloned.content
is the actual value returned when doing either var content = template.render()
or template.render(function (err, content) { ... });
.
We're going to have to basically do a "clone" on the cloned object to get all the changed properties to sync with the template object and make sure that the content doesn't change on the original template object, but still return the cloned content string.
Actually, this might not be an issue now that the templates are pre-compiled. Cloning was added before that was in there to ensure the partials can be rendered multiple times. Now that they get pre-compiled, the original template.content
can be updated and it won't be affected because the compiled piece will still be there on template.fn
.
I'll try out some things and let you know.
That's exactly what I was wondering, about the compiled functions. thanks for clarifying
This section of code is what I'm referring to here:
cloned
template is updated with the rendered content and passed to anypostRender
middleware to allow modifying the content if needed.postRender
is done, thecloned.content
is passed back to the caller.This makes it so users that want to modify something else in a
postRender
middleware can't because the changes only affect the cloned object and are lost. The common case for this is changingpath
after rendering.Should we allow changing other properties in
postRender
? I think the better way to do it is inpreRender
since the properties will be updated for use during the rendering process.