I'm playing with dust examples on dust test page http://linkedin.github.com/dustjs/test/test.html and in the same time in node.js (0.8.15), express.js(3.0.4), consolidate(0.0.5), dust-linkedin(1.1.1).
If I execute my template on dust test page (see link at the top) it works well:
<a href="/en/subjects/subject-1-page-id">subject 1 title en</a>
It renders subject 1 title en
If I execute my templte on node/express/consolidate/dust is shows:
<a href="/en/subjects/subject-2-page-id">{locale[lang].title}</a>
It renders {locale[lang].title}
here is my template:
{#subjects lang=language}
<div>
<img src="/files/subjects/{logo}" />
<div>
<a href="/{lang}/subjects/{pageId}">{locale[lang].title}</a>
</div>
</div>
{~n}
{/subjects}
here is my JSON object:
{
language: 'en',
subjects: [
{
logo: 'subject1.jpg',
pageId: 'subject-1-page-id',
locale: {
en: { title: 'subject 1 title en' },
fr: { title: 'subject 1 title fr' },
}
}
]
}
here is rendered template from dust test site:
<div>
<img src="/files/subjects/subject1.jpg" />
<div>
<a href="/en/subjects/subject-1-page-id">subject 1 title en</a>
</div>
</div>
here is rendered templete from node/express/consolidate/dust-linkedin
<div>
<img src="/files/subjects/subject1.jpg" />
<div >
<a href="/en/subjects/subject-1-page-id">{locale[lang].title}</a>
</div>
</div>
here is the part of compiled template from dust test page (see link at the top):
.write("\">").reference(ctx.getPath(false, ["locale", ctx.get("lang"), "title"]), ctx, "h").write("</a></div></div>\n");
and here is the part compiled on server when I'm using {locale[lang].title}.
.write("\">{locale[lang].title}</a></div></div>\n");
and here is the part compiled on server when I'm using {locale.en.title}
.write("\">").reference(ctx.getPath(false, ["locale", "en", "title"]), ctx, "h").write("</a></div></div>\n");
If I try to render {locale.en.title} on node - it works.
Please note lang variable always works in the <a href='/en/ ...> link
And my question is : why in browser dust parse my path well, but on node doesn't work? Or, how to render object using 'array-like' key access