Skip to content

RFC: slightly expand "as" expressions #3

@jamesarosen

Description

@jamesarosen

One feature that Ember's Handlebars offers is the ability for blocks to yield an object:

{{#my-details as |details|}}
  <button onclick={{details.toggle}}>
   {{#if details.isOpen 'Close' 'Open'}}
  <button>

  {{#if details.isOpen}}
    the content that gets toggled
  {{/if}}
{{/my-details}}

The HTMLX feature that comes closest is {#each cats as cat}. If you loosen the syntax just slightly to allow a JavaScript express instead of each cats, but still only allow a single yielded object, the above could be written as

{#new MyDetails() as |details|}
  <button onclick={details.toggle}>
   {details.isOpen ? 'Close' 'Open'}
  <button>

  {#if details.isOpen}
    the content that gets toggled
  {/if}
{/as}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions