linkedin / linkedin/dustjs

Would it be possible to pass a sub-tree as parameter to a partial?

Open
#715 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Apologies if this has been previously discussed or is simply unpractical to implement, but I wish there as a way to pass a sub-tree of DOM elements to a partial as a parameter.

_Example:_

```

{>"components/my-component1" parameter1="foobar"}


Hello world



{<}
```

```


{_content}

```

_Result:_

```



Hello world




```

This would allow developers to create self-contained and reusable components as Dust.js partials. You can argue that this is technically possible now, but one would have to pass any markup required by the component as a normal parameter, which can get messy very easily:

```
{>"components/my-component1" parameter1="foobar" content="

Hello world

"}
```

A similar approached is used by Sass in their mixins, as developers can define normal parameters as well a special code block defined as `@content`.

``` scss
@mixin component1($arg1, $arg) {
.component1 {
width: $arg1;
height: $arg2;
@content;
}
}
```

React components also make this possible through `this.props.children`.

I'd love to hear your thoughts about this. Thanks in advance!

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

Start by reviewing how Dust.js currently handles partial parameters and nested markup, then compare that behavior with the requested call-site and partial examples. Done would mean agreeing on a supported syntax and behavior for passing the nested subtree while preserving existing partial usage.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.