Open
Conversation
If options.settings['theme'] is set by calling
"app.set('theme', __dirname + '/themes/' + storeConfig.ActiveTheme);"
then all templates will be loaded from the themes folder if they exist.
If they don't exists templates will be loaded as usual.
index.js
Outdated
Owner
There was a problem hiding this comment.
I think the call to existsSync should be cached in production apps.
Author
There was a problem hiding this comment.
Yes that makes sense. Not sure how to do this but will take a look.
Could the current view cache be used?
Author
There was a problem hiding this comment.
Would something like this work for the current cache
var engine = options.settings['view engine'] || 'ejs'
, desiredExt = '.' + engine
, ext = extname(file) || desiredExt
, key = [themeFilePath, file, ext].join('-');
//Check if the file has already been resolved in the theme folder to avoid io
if (options.cache && cache[key]) file = cache[key];
if (fs.existsSync(resolve(themeFilePath, basename(file)))) {
cache[key] = resolve(themeFilePath, basename(file));
file = resolve(themeFilePath, basename(file));
}
Owner
|
This looks simple enough - can you add some tests maybe an example? Apologies up-front that the tests are a little bit of a rats' nest, feel free to start a separate file. |
Added the use of the cache object to store templates that have already been resolved in the theme folder
|
+1 Any progress with this? By the way as a workaround it would be awesome if relative paths worked. Seems to fail with good old |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If options.settings['theme'] is set by calling
"app.set('theme', __dirname + '/themes/' + storeConfig.ActiveTheme);"
then all templates will be loaded from the themes folder if they exist.
If they don't exist templates will be loaded as usual.