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

self-references #332

Merged
merged 1 commit into from
Mar 4, 2017
Merged

self-references #332

merged 1 commit into from
Mar 4, 2017

Conversation

Rich-Harris
Copy link
Member

Ref #51. This PR adds self-references, so that a component can do this sort of thing:

<article class='file {{file.type}}'>
  {{file.name}}

  {{#if file.type === 'folder'}}
    <ul>
      {{#each file.children as child}}
        <li><:Self file='{{child}}'/></li>
      {{/each}}
    </ul>
  {{/if}}
</article>

I went with :Self because it doesn't interfere with syntax highlighting (at least in the places I've looked), and using a special name over other mechanisms (like late-binding components, or using a special keyword like this inside the components object) means that we can easily guard against infinite recursion by ensuring that it's only used inside if or each blocks.

@Rich-Harris Rich-Harris merged commit 319b3b6 into master Mar 4, 2017
@Rich-Harris Rich-Harris deleted the gh-51 branch March 4, 2017 05:12
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

Successfully merging this pull request may close these issues.

1 participant