Adding a filter in an express mounted app overwrites filter of the same name in the parent app
Hello,
I have an admin express app that I mount in another express app like this:
var admin = new Admin();
app.use('/admin', admin.app);
Both apps use ejs and both apps add custom filters, one of which has the same name but different semantics and implementation. As ejs filters are stored at the module level, the filter of the mounted app overwrites the filter with the same name in the parent app and breaks all the views that use this filter.
As a workaround, I converted the filters to helper functions in res.locals for the admin app, so that it does not interfere with the parent app, but this creates a less readable template.
From my understanding of the ejs code, there is no solution to expose filters only to an app and not to all users of the module. Can you confirm this?
What would you suggest to solve this issue?
Regards,
Laurent