MCPcopy Index your code
hub / github.com/ember-polyfills/ember-named-blocks-polyfill

github.com/ember-polyfills/ember-named-blocks-polyfill @v0.2.5

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.2.5 ↗ · + Follow
69 symbols 162 edges 25 files 43 documented · 62% 2 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ember-named-blocks-polyfill

This addon provides a polyfill for the Yieldable Named Blocks feature. On Ember.js versions with native support for the feature (3.25+), this addon is inert.

Compatibility

  • Ember.js v3.12.4 or above
  • Ember CLI v2.13 or above
  • Node.js v10 or above

Installation

ember install ember-named-blocks-polyfill

Usage

To pass named blocks to a component:

<FancyList @items={{@model}}>
  <:header>This list is <em>fancy</em>!</:header>
  <:row as |item|>
    {{#if item.isHotTip}}
      <h2>Hot Tip&trade;</h2>


{{item}}


    {{/if}}
  </:row>
</FancyList>

To yield to named blocks:

<header class="fancy-list-header">
  {{yield to="header"}}
</header>

<ul>
  {{#each @items as |item|}}
    <li>{{yield item to="row"}}</li>
  {{/each}}
</ul>

{{#if (has-block "footer")}}
  {{yield to="footer"}}
{{else}}
  <footer>Powered by &lt;FancyList&gt;</footer>
{{/if}}

See the RFC for more information on the named blocks feature.

Limitations

This addon aims to be a high fidelity polyfill both in syntax and semantics. However, there are some minor limitations:

  • It is not currently possible to pass an <:else> or <:inverse> named block. See #1.

  • When passing only named blocks (without passing a <:default> block) to an addon component whose template was not preprocessed by this polyfill, {{has-block}} in that component's template will return true.

This is unlikely to be an issue in practice – if you are running an Ember version that requires this polyfill and the addon itself is not also using the polyfill, it problably means that the addon component you are invoking does not accept named blocks anyway, so there is no use in passing them.

See #4.

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Extension points exported contracts — how you extend this code

CommonProgram (Interface)
(no doc)
lib/glimmer-syntax-polyfill.d.ts
Block (Interface)
(no doc)
lib/glimmer-syntax-polyfill.d.ts
Template (Interface)
(no doc)
lib/glimmer-syntax-polyfill.d.ts
Nodes (Interface)
(no doc)
lib/glimmer-syntax-polyfill.d.ts

Core symbols most depended-on inside this repo

check
called by 26
lib/named-blocks-polyfill-plugin.js
assert
called by 18
lib/named-blocks-polyfill-plugin.js
path
called by 11
lib/named-blocks-polyfill-plugin.js
push
called by 8
lib/named-blocks-polyfill-plugin.js
guard
called by 6
lib/named-blocks-polyfill-plugin.js
transformHasBlock
called by 4
lib/named-blocks-polyfill-plugin.js
isSimplePath
called by 3
lib/named-blocks-polyfill-plugin.js
blockItself
called by 3
lib/named-blocks-polyfill-plugin.js

Shape

Method 33
Function 24
Class 8
Interface 4

Languages

TypeScript100%

Modules by API surface

lib/named-blocks-polyfill-plugin.js51 symbols
index.js7 symbols
lib/glimmer-syntax-polyfill.d.ts4 symbols
addon/index.js3 symbols
tests/dummy/app/router.js2 symbols
tests/dummy/app/app.js2 symbols

Used by 2 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add ember-named-blocks-polyfill \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page