Skip to content
This repository has been archived by the owner on Jan 25, 2020. It is now read-only.

Add support for multiple view folders #110

Open
wants to merge 3 commits into
base: v1.x
Choose a base branch
from

Conversation

claviska
Copy link

@claviska claviska commented May 5, 2017

This PR addresses the fixme in engine.js by adding support for multiple view folders as introduced in Express 4.10.

The solution looks for a matching template in all folders defined by app.set('views'). Checks run in serial to ensure consistent behavior, starting with the first folder and ending with the last.

Use Cases

One use case for this allows users to set a fallback directory in case a template is missing.

My personal use case is for Postleaf, where users can create their own themes and, if a template is missing, we fall back to a system template in a different location. Postleaf also uses this feature to support rendering admin views and theme views from a single app instance.

Tests

I'm not super familiar with Mocha, but I ran the tests and all 75 are passing. ✅

It may be worth creating a new test for this patch, though. Maybe a maintainer could point me in the right direction?

@grawk
Copy link
Member

grawk commented Nov 9, 2017

Hi @claviska I apologize about the lag. I agree that unit tests would be in order here. Do you want to take a crack at that?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants