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

Optionality for partials #3337

Open
daytonlowell opened this issue Aug 18, 2020 · 3 comments
Open

Optionality for partials #3337

daytonlowell opened this issue Aug 18, 2020 · 3 comments

Comments

@daytonlowell
Copy link

Description:

Currently, if you have a partial that never gets referenced, Ractive will put a warning in the console like

Could not find template for partial '<named yield>'

Sometimes I would like to mark a partial as optional. This comes up most often in components where I'll created named yields that the consumer of the component may not be interested in actually using(depending on their use-case).

Perhaps something like {{yield?}} and {{>?}} would suppress the warning.

Versions affected:

all

Platforms affected:

all

Reproduction:

N/A

@MartinKolarik
Copy link
Member

👍 this is something I've run into as well and should be fairly simple to add.

@evs-chris
Copy link
Contributor

It just occurred to me that you could also supply a default partial (see foo) in the component to avoid this e.g.

Ractive.extend({
  template: '<div>{{yield something}}</div>',
  partials: {
    something: []
  }
});

Would that be an acceptable workaround, or is optional syntax more clear here? From the perspective of a function call, function fn(foo?: Foo) and function fn(foo: Foo = {}) are subtly but definitely different.

@daytonlowell
Copy link
Author

The optional syntax may be more clear, but supplying a default partial totally works for my use case. Thanks.

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

No branches or pull requests

3 participants