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

Extend partials #346

Open
norlin opened this issue Oct 8, 2013 · 2 comments
Open

Extend partials #346

norlin opened this issue Oct 8, 2013 · 2 comments
Labels

Comments

@norlin
Copy link

norlin commented Oct 8, 2013

For example, I have little html-snippet

<div class="my-little-block">
    <h3 class="title">{title}</h3>
    <div class="little-block-content">{content}</div>
</div>

How I could reuse this snippet in my template?
E.g., I need template like this:

{?dust}
<div class="my-little-block">
    <h3 class="title">My first block</h3>
    <div class="little-block-content">
        <div>...more html with {some} {params}...</div>
    </div>
</div>
{:else}
<div class="my-little-block">
    <h3 class="title">Look ma, table!</h3>
    <div class="little-block-content">
        <table>some other html {with} {different} {data}</table>
    </div>
</div>
{/else}

And I want not to copy-paste html-layout for my little block, but use some partial with it. Now I can't do this...

Something like this:

{?cond}
    {>myLittleBlock}
        {<title}My first block{/title}
        {<content}
            <div>...more html with {some} {params}...</div>
        {/content}
    {/myLittleBlock}
{:else}
    {>myLittleBlock}
        {<title}Look ma, table!{/title}
        {<content}
            <table>some other html {with} {different} {data}</table>
        {/content}
    {/myLittleBlock}
{/cond}
@rragan
Copy link
Contributor

rragan commented Oct 9, 2013

You seem to be looking for a template that can take simple parameters and large chunks of code as a parameter value. I've got a dust helper that should meet your needs.

http://rragan.github.io/dust-motes/docs/helpers-html.html
https://github.com/rragan/dust-motes/blob/master/src/helpers/html/layout.js

Somewhat related is the @provide helper, combined with a simple partial it could do what you need.

http://rragan.github.io/dust-motes/docs/helpers-data.html
https://github.com/rragan/dust-motes/blob/master/src/helpers/data/provide.js

@prashn64
Copy link
Contributor

Related to PR #358

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

No branches or pull requests

3 participants