knockout.slot

Composing template with <slot>.

Usage no npm install needed!

<script type="module">
  import knockoutSlot from 'https://cdn.skypack.dev/knockout.slot';
</script>

README

knockout.slot

Knockout components are very similar to Custom Elements, which are part of Web Components Spec.This plugin implement the very basic Slot API.

Usage

Install from NPM:

npm install knockout.filter --save
<script src="knockout.3.4.0.js"></script>
<script src="./node_modules/knockout.fitler/dest/knockout.slot.js"></script>

Example

son.tpl

<div class="son">
    <slot name="a">old</slot>
</div>

parent.tpl

<div class="parent">
    <son>
        <slot name="a">new</slot>
    </son>
</div>

yield:

<div class="parent">
    <son>new</son>
</div>

License

MIT © [BinRui.Guan](mailto: differui@gmail.com)