linkedin / linkedin/dustjs

Extend partials

Open
#346 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
JavaScript
Stars
2.9k
Forks
461
PR merge metrics
No merged PRs in 30d

Description

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}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue gives example HTML snippets and Dust partial/conditional syntax but names no source file or test. Start by locating the existing partial and conditional handling, then define how a reusable partial accepts title and content blocks. Done means the shown conditional examples render both variants without duplicating the block layout.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.