Comments (24)
I'd love to know what your config looks like -- things moved around a bit.
from makara.
Thanks, here is my current config.json:
{
"express": {
"view cache": false,
"view engine": "dust",
"views": "path:./.build/templates"
},
"view engines": {
"dust": {
"module": "makara",
"renderer": {
"method": "dust",
"arguments": [
{ "cache": false, "helpers": "config:dust.helpers" }
]
}
}
},
"bundle engine": "dust",
"specialization": "import:./specialization.json",
"i18n": {
"contentPath": "path:./locales",
"fallback": "en-US"
},
"databaseConfig": {
"host": "localhost",
"database": "shocart"
},
"dust": {
"helpers": [
"dust-makara-helpers"
]
},
"paypalConfig": {
"host": "api.sandbox.paypal.com",
"port": "",
"client_id": "EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM",
"client_secret": "EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM"
},
"middleware": {
"expressView": {
"priority": 100,
"enabled": true,
"module": {
"name": "makara",
"arguments": [
{
"i18n": "config:i18n",
"specialization": "config:specialization"
}
]
}
},
"static": {
"module": {
"arguments": [ "path:./.build" ]
}
},
"router": {
"module": {
"arguments": [ { "directory": "path:./controllers" } ]
}
},
"fileNotFound": {
"enabled": true,
"priority": 130,
"module": {
"name": "kraken-js/middleware/404",
"arguments": [ "errors/404" ]
}
},
"serverError": {
"enabled": true,
"priority": 140,
"module": {
"name": "kraken-js/middleware/500",
"arguments": [ "errors/500" ]
}
},
"locale": {
"priority": 95,
"enabled": true,
"module": {
"name": "path:./lib/locale"
}
}
}
}
And the specialization.json file:
{
"noprods": [
{
"is": "shopsite/noprods",
"when": {
"template.is": "shopsite"
}
}
]
}
I am passing the config like this:
model.template = {
is: "shopsite"
};
res.render('index', model);
And before the upgrade shopsite/noprods.dust was getting rendered, now only ./noprods.dust seems to come up.
from makara.
Hrm. At a glance that looks right -- you don't need the indirection of using both import:
and config:
handlers, you could just import it right into the config, but I see no error there.
Can you run your app with the NODE_DEBUG=engine-munger
environment variable? That should print out debug tracing and show where it went wrong.
from makara.
ENGINE-MUNGER 14116: specialization mapped 'index.dust' to 'index.dust'
ENGINE-MUNGER 14116: lookup "index.dust"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\public\templates\index.dust"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\public\templates\index.dust"
ENGINE-MUNGER 14116: render "M:\web\node\webtrade\public\templates\index.dust"
ENGINE-MUNGER 14116: specialization mapped 'index.properties' to 'index.properti
es'
ENGINE-MUNGER 14116: trying locales ["US/en"]
ENGINE-MUNGER 14116: lookup "index.properties"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\locales\US\en\index.properties"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\locales\US\en\index.properties"
ENGINE-MUNGER 14116: specialization mapped 'index.properties' to 'index.properti
es'
ENGINE-MUNGER 14116: trying locales ["US/en"]
ENGINE-MUNGER 14116: lookup "index.properties"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\locales\US\en\index.properties"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\locales\US\en\index.properties"
ENGINE-MUNGER 14116: specialization mapped 'layouts/master.dust' to 'layouts/mas
ter.dust'
ENGINE-MUNGER 14116: lookup "layouts/master.dust"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\public\templates\layouts\master.
dust"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\public\templates\layouts\master
.dust"
ENGINE-MUNGER 14116: specialization mapped 'layouts/master.properties' to 'layou
ts/master.properties'
ENGINE-MUNGER 14116: trying locales ["US/en"]
ENGINE-MUNGER 14116: lookup "layouts/master.properties"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\locales\US\en\layouts\master.pro
perties"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\locales\US\en\layouts\master.pr
operties"
ENGINE-MUNGER 14116: specialization mapped 'layouts/master.properties' to 'layou
ts/master.properties'
ENGINE-MUNGER 14116: trying locales ["US/en"]
ENGINE-MUNGER 14116: lookup "layouts/master.properties"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\locales\US\en\layouts\master.pro
perties"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\locales\US\en\layouts\master.pr
operties"
ENGINE-MUNGER 14116: specialization mapped 'noprods.dust' to 'noprods.dust'
ENGINE-MUNGER 14116: lookup "noprods.dust"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\public\templates\noprods.dust"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\public\templates\noprods.dust"
ENGINE-MUNGER 14116: specialization mapped 'noprods.properties' to 'noprods.prop
erties'
ENGINE-MUNGER 14116: trying locales ["US/en"]
ENGINE-MUNGER 14116: lookup "noprods.properties"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\locales\US\en\noprods.properties
"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\locales\US\en\noprods.propertie
s"
ENGINE-MUNGER 14116: specialization mapped 'noprods.properties' to 'noprods.prop
erties'
ENGINE-MUNGER 14116: trying locales ["US/en"]
ENGINE-MUNGER 14116: lookup "noprods.properties"
ENGINE-MUNGER 14116: stat "M:\web\node\webtrade\locales\US\en\noprods.properties
"
ENGINE-MUNGER 14116: found "M:\web\node\webtrade\locales\US\en\noprods.propertie
s"
from makara.
if I put {template.is} into the index.dust file it shows the value of "shopsite", which should trigger the alternate partial if I have all the bits lined up correctly.
from makara.
Oh! I bet I know what it is. Change your specialization map to include the extension on the filename of the template.
from makara.
Thanks, but still the same (but different) - there's a lot of 404 stuff in the debug log now, but the rendered output looks the same.
ENGINE-MUNGER 3888: specialization mapped 'errors/404.dust' to 'errors/404.dust'
ENGINE-MUNGER 3888: lookup "errors/404.dust"
ENGINE-MUNGER 3888: stat "M:\web\node\webtrade\public\templates\errors\404.dust"
ENGINE-MUNGER 3888: found "M:\web\node\webtrade\public\templates\errors\404.dust
"
ENGINE-MUNGER 3888: render "M:\web\node\webtrade\public\templates\errors\404.dus
t"
ENGINE-MUNGER 3888: specialization mapped 'errors/404.properties' to 'errors/404
.properties'
ENGINE-MUNGER 3888: trying locales ["US/en"]
ENGINE-MUNGER 3888: lookup "errors/404.properties"
ENGINE-MUNGER 3888: stat "M:\web\node\webtrade\locales\US\en\errors\404.properti
es"
ENGINE-MUNGER 3888: found "M:\web\node\webtrade\locales\US\en\errors\404.propert
ies"
ENGINE-MUNGER 3888: specialization mapped 'errors/404.properties' to 'errors/404
.properties'
ENGINE-MUNGER 3888: trying locales ["US/en"]
ENGINE-MUNGER 3888: lookup "errors/404.properties"
ENGINE-MUNGER 3888: stat "M:\web\node\webtrade\locales\US\en\errors\404.properti
es"
ENGINE-MUNGER 3888: found "M:\web\node\webtrade\locales\US\en\errors\404.propert
ies"
ENGINE-MUNGER 3888: specialization mapped 'layouts/master.dust' to 'layouts/mast
er.dust'
ENGINE-MUNGER 3888: lookup "layouts/master.dust"
ENGINE-MUNGER 3888: stat "M:\web\node\webtrade\public\templates\layouts\master.d
ust"
ENGINE-MUNGER 3888: found "M:\web\node\webtrade\public\templates\layouts\master.
dust"
ENGINE-MUNGER 3888: specialization mapped 'layouts/master.properties' to 'layout
s/master.properties'
ENGINE-MUNGER 3888: trying locales ["US/en"]
ENGINE-MUNGER 3888: lookup "layouts/master.properties"
ENGINE-MUNGER 3888: stat "M:\web\node\webtrade\locales\US\en\layouts\master.prop
erties"
ENGINE-MUNGER 3888: found "M:\web\node\webtrade\locales\US\en\layouts\master.pro
perties"
ENGINE-MUNGER 3888: specialization mapped 'layouts/master.properties' to 'layout
s/master.properties'
ENGINE-MUNGER 3888: trying locales ["US/en"]
ENGINE-MUNGER 3888: lookup "layouts/master.properties"
ENGINE-MUNGER 3888: stat "M:\web\node\webtrade\locales\US\en\layouts\master.prop
erties"
ENGINE-MUNGER 3888: found "M:\web\node\webtrade\locales\US\en\layouts\master.pro
perties"
My spec file is now
{
"noprods": [
{
"is": "shopsite/noprods.dust",
"when": {
"template.is": "shopsite"
}
}
]
}
from makara.
try
{
"noprods.dust": [
{
"is": "shopsite/noprods.dust",
"when": {
"template.is": "shopsite"
}
}
]
}
from makara.
ENGINE-MUNGER 3300: specialization mapped 'index.dust' to 'index.dust'
ENGINE-MUNGER 3300: lookup "index.dust"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\public\templates\index.dust"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\public\templates\index.dust"
ENGINE-MUNGER 3300: render "M:\web\node\webtrade\public\templates\index.dust"
ENGINE-MUNGER 3300: specialization mapped 'index.properties' to 'index.propertie
s'
ENGINE-MUNGER 3300: trying locales ["US/en"]
ENGINE-MUNGER 3300: lookup "index.properties"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\locales\US\en\index.properties"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\locales\US\en\index.properties"
ENGINE-MUNGER 3300: specialization mapped 'index.properties' to 'index.propertie
s'
ENGINE-MUNGER 3300: trying locales ["US/en"]
ENGINE-MUNGER 3300: lookup "index.properties"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\locales\US\en\index.properties"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\locales\US\en\index.properties"
ENGINE-MUNGER 3300: specialization mapped 'layouts/master.dust' to 'layouts/mast
er.dust'
ENGINE-MUNGER 3300: lookup "layouts/master.dust"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\public\templates\layouts\master.d
ust"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\public\templates\layouts\master.
dust"
ENGINE-MUNGER 3300: specialization mapped 'layouts/master.properties' to 'layout
s/master.properties'
ENGINE-MUNGER 3300: trying locales ["US/en"]
ENGINE-MUNGER 3300: lookup "layouts/master.properties"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\locales\US\en\layouts\master.prop
erties"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\locales\US\en\layouts\master.pro
perties"
ENGINE-MUNGER 3300: specialization mapped 'layouts/master.properties' to 'layout
s/master.properties'
ENGINE-MUNGER 3300: trying locales ["US/en"]
ENGINE-MUNGER 3300: lookup "layouts/master.properties"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\locales\US\en\layouts\master.prop
erties"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\locales\US\en\layouts\master.pro
perties"
ENGINE-MUNGER 3300: specialization mapped 'noprods.dust' to 'noprods.dust'
ENGINE-MUNGER 3300: lookup "noprods.dust"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\public\templates\noprods.dust"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\public\templates\noprods.dust"
ENGINE-MUNGER 3300: specialization mapped 'noprods.properties' to 'noprods.prope
rties'
ENGINE-MUNGER 3300: trying locales ["US/en"]
ENGINE-MUNGER 3300: lookup "noprods.properties"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\locales\US\en\noprods.properties"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\locales\US\en\noprods.properties
"
ENGINE-MUNGER 3300: specialization mapped 'noprods.properties' to 'noprods.prope
rties'
ENGINE-MUNGER 3300: trying locales ["US/en"]
ENGINE-MUNGER 3300: lookup "noprods.properties"
ENGINE-MUNGER 3300: stat "M:\web\node\webtrade\locales\US\en\noprods.properties"
ENGINE-MUNGER 3300: found "M:\web\node\webtrade\locales\US\en\noprods.properties
"
With spec file:
{ "noprods.dust": [ { "is": "shopsite/noprods.dust", "when": { "template.is": "shopsite" } } ] }
Same rendered output as before
from makara.
Well nuts! that should work!
from makara.
This is running on Windows Server 2012 with latest node.js if that helps
from makara.
I'll have to try later -- I've my job to get to at the moment, but I may see if I can delve into this in the kraken specialization sample app and upgrade that to makara 2.
from makara.
Ok cool, yes it would be good to have a standard example to work with. Can confirm a rollback to earlier code works as expected on the same machine.
from makara.
Quick question (I'm still a bit of a node noob) is it possible to have a dynamic specialization, so that the controller defines the mapping so I don't need to restart the app every time I make a change?
from makara.
Not as it stands -- might be able to tweak the map if you can get a reference to it, but I'd have to see if it's cleanly exposed or not.
from makara.
Ok thanks, have had a quick look and can see it being assigned in engine-munger but any hints or tips as to when and where to hook into the render process would be welcome :)
from makara.
I'm up to my elbows in the guts right now and it looks like the main templates should be working properly, but partials aren't passing the full information, and therefore aren't being specialized.
from makara.
Yes, that sounds like what was happening
from makara.
So yes, I can confirm this is a bug. It's actually a bug in adaro, which should be fixed by krakenjs/adaro#92
from makara.
Cool, great, thanks for fixing it so fast :) What do I need to do to test it? Can I do an npm update, or manually patch the code my side?
from makara.
You can install the module from the git branch to test, or apply my changes -- they're simple -- to your existing copy.
from makara.
ok I'll apply your changes directly. Also I'm very keen on setting up dynamic specialization if you have any pointers in that regard. Thank you very much for your help.
from makara.
kraken is going to fight you a bit on the dynamic specialization. It does a bit of extra work to keep people from using the config as a data store shared among modules -- so mutating it is hard.
How hard on your workflow is it to just restart the server on change with something like nodemon?
from makara.
Ok thanks I'll give that a go, I haven't used nodemon before, so appreciate the tip
from makara.
Related Issues (20)
- multi
- Plan for makara deprecation HOT 6
- Add support for formatPath in Bundalo.
- dust helpers documentation is wrong HOT 1
- Express app stops responding if there are too many partial includes HOT 6
- Makara doesn't look up localised templates HOT 3
- Problem with format path HOT 3
- Makara 2 and Dust @provide helper HOT 3
- Makara 2 with locale from cookie is not localizing templates HOT 1
- Upgrading makara: client side HOT 9
- Locale specific templates HOT 4
- Build task on windows fails due to OS path separator issue HOT 4
- is there a concept of fallback at the level of the Country HOT 3
- Question: what are the various ways to manually set the expressjs-res's locale HOT 4
- I can't pass the enableMetadata parameter HOT 2
- Don't load req.locale HOT 1
- Update the bundalo to 1.x to remove dependency from dustjs-linkedin HOT 1
- is makara only for dustjs template engine?
- Update bundalo for security issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from makara.