Skip to content
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

Be able to grab the rendered contents of individual layouts #587

Open
balupton opened this issue Aug 7, 2013 · 1 comment
Open

Be able to grab the rendered contents of individual layouts #587

balupton opened this issue Aug 7, 2013 · 1 comment

Comments

@balupton
Copy link
Member

balupton commented Aug 7, 2013

Right now, if we want to include the rendered content of a particular layout (but not all of them) in a content listing then we have to move that layout into a partial and include it in the document's content - as we either have document.contentRendered that includes the rendered content of all layouts, or document.contentRenderedWithoutLayouts with no layouts - nothing in between

It would be nice to have something like document.contentRenderedWithLayout as an object containing the rendered content of each layout inside it, as well as an array of the order. So we could do document.contentRenderedWithLayout.page to fetch the data of the page layout (wraps the content in an article) and not with the default layout (wraps the content in html structure). We could also do document.contentRenderedWithLayout[0] to get the first layout rendered perhaps.

This would allow us to do something like this:

<h2>Posts:</h2>
<ul><% for post in @getFilesAtPath('posts/').toJSON(): %>
    <li>
        <%- post.contentRenderedWithLayout.page %>
    </li>
<% end %></ul>

Would output this:

<h2>Posts:</h2>
<ul>
    <li>
        <article>
            <h1>Post 1</h1>
            <div>Post 1 data</div>
        </article>
    </li>
    <li>
        <article>
            <h1>Post 2</h1>
            <div>Post 2 data</div>
        </article>
    </li>
</ul>

Reference structure is here: docpad/docpad-plugin-multiplelayouts#1


Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.

@greduan
Copy link
Contributor

greduan commented Aug 7, 2013

Oh this sounds very nice... ETA? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants