pug - Adding navigation to a partial in Docpad -
is possible add site navigation partial file?
i keep things clean in documents , prefer seperating out navigation have been having problems in docpad when add navigation partial file.
i using jade instead of eco. when place navigation in default.html.md.jade file works perfectly.
when put code in partials/nav.html.jade error: warning: went wrong while rendering: html5-boilerplate.docpad/src/partials/nav.html.jade
and shows in compiled html:
<header>typeerror: object #<object> has no method 'getcollection'</header>
this navigation code:
nav ul each doc in getcollection('pages').tojson() - clazz = (document.url === doc.url) ? 'active' : null li(class=clazz) a(href=doc.url, title=doc.title)= doc.title
and how set collections inside docpad.coffee
collections: pages: (database) -> database.findalllive({pageorder: $exists: true}, [pageorder:1,title:1]) posts: (database) -> database.findalllive({relativeoutdirpath:'posts'},[date:-1])
update: partials plugin v2.8.0+ includes template data default, things should work without having manually specify include template data. see partial plugin page more info.
by default, partials not have template data (for speed reasons). access template data, can pass on partial call (in eco, not familiar jade): <%- @partial('the-partial-location', @) %>
. can more precisely , performant passing on need so: <%- @partial('the-partial-location', {something:@something, somethingelse: @somethingelse) %>
more info here
Comments
Post a Comment