-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configure kracken to use only X view engine #94
Comments
you would need to specify in the config "view engines" (the list of all possible engines you would like to use) and "express:view engine" in the config - and specify your module, that will provide the engine middleware to be used for view engine. From there you would have total control on rendering. |
check this line out, as to how kraken sets view engine up... https://github.com/paypal/kraken-js/blob/master/lib/appcore.js#L124 |
The problem is that kraken will always include dust and js by default. See https://github.com/paypal/kraken-js/blob/master/config/webcore.json#L23. It is currently possible to opt out of all template rendering (see https://github.com/paypal/kraken-js/blob/master/lib/appcore.js#L76) by setting express:view engine to null. However, as far as I can see, if you want any template rendering at all, there is currently no way to opt out of dust and js. If you look at https://github.com/paypal/kraken-js/blob/master/lib/util/configutil.js#L244 you can see that nconf is configured with my app's custom config and then with the kraken defaults (webcore). It is webcore which includes dust and js view engines, and there is no way I can see to remove them. |
I am not sure it will if you specify "view engines" in your app's config. I think your app's view engines config will override the default in webcore.json. {
"view engines": {
"ejs": {
"module": "myModule",
"settings" : {<mySettings>}
}
}
} |
Yes, it is additive, so the above config will result in 3 view engines - dust, js and ejs. Add the following line at https://github.com/paypal/kraken-js/blob/master/lib/appcore.js#L131
|
ahhh then i think i know what is happening. DO you have i18n enabled and using makara ? |
I'm just using the default config as created by
I see that https://github.com/paypal/kraken-js/blob/master/config/webcore.json#L13 configures i18n by default. That means https://github.com/paypal/kraken-js/blob/master/lib/appcore.js#L108 will get back a non-null string, and therefore https://github.com/paypal/kraken-js/blob/master/lib/appcore.js#L145 will pass and makara will be included. What are your thoughts because I don't see how i18n config will have any affect on the multiple "view engines" entries? |
When i18n is enabled, Inside makara, the view engine gets force switched back to js so that we can apply localization to the dust templates I think I see 2 issues: |
To me it seems like fixing the above 2 is the right solve for your issue. |
Ok, thanks. So to get ejs template rendering to work I had to set "express:view engine" as well. I use .html extension for my ejs templates. It looks as if this code (https://github.com/paypal/makara/blob/master/index.js#L62) will also break then? Not too sure as I'm not in front of my computer. I'll also dig deeper once back at my machine. Thanks again |
I am not sure either. But let me work on switching off i18n working first. That should solve the overriding your engine aspect. |
I'm in front of my computer now... It turns out for my use case (parse That is because However, that said, special casing |
Unfortunately, the mapping of '.html' to ejs templates isn't supported yet. That will have to be filed as a feature issue. I was able to use ejs by doing the following: $ yo kraken
$ cd ejs-kraken
$ npm install --save consolidate
$ npm install --save ejs app.json{
"i18n": null,
"view engines": {
"ejs": {
"module": "consolidate"
}
},
"express": {
"view engine": "ejs"
}
} index.ejs
This renders templates with the $ npm start
# ...
$ curl :8000
Hello, ejs! |
I got I added another option This means that the following config will cause express to render
You can also achieve the same thing without
|
Sweet, thanks @skeganga |
+1 @skeganga , I will have to try your method out :) |
+1 |
Closing this out as this is a non-issue now that the .next branch has been merged into master. The rendering engine (and all middleware) has been decoupled from the main kraken codebase. If you're daring, there's an early release candidate published on npm as |
I'm looking for pointers on how to disable the default
dust
andjs
view engines, and replace them withejs
.I've seen from pull-request #61 that it is now possible to completely disable view engines.
However, I would like to disable
dust
and enableejs
The text was updated successfully, but these errors were encountered: