Palette
    Preparing search index...

    Class Template

    A renderable template from an HTMLTemplateElement

    Leverages a simple syntax to provide accessors to template data from one of four categories, based on use case:

    Prefix Namespace
    @ The attr namespace (host element attributes)
    $ The state namespace (component reactive state)
    * The data namespace (component computed props)
    # The item namespace (list item context)

    Bind attributes to a value using the :attribute syntax:

    <div :id="$id" :class="@classname"></div>
    

    Or use directives with notations for advanced templating:

    <div ::if="*showList">
    <ul>
    <li ::each="$items" ::key="#id">
    <span ::swap="#content"></span>
    </li>
    </ul>
    </div>
    Index

    Constructors

    • Parameters

      • template: HTMLTemplateElement

      Returns Template

    Properties

    cache: { clear: () => void; setCapacity: (maxSize: number) => void } = ...

    Properties related to the global Template build cache.

    This is not something typically needed for general app development, but allows for advanced configuration to tune the caching system if need be.

    Cache sizes default to 500 HTML Template Fragments and compiled Palette templates (includes nested templates like lists) to cover most application needs without using much memory.

    Type Declaration

    • clear: () => void

      Wipe all cached templates and HTML fragments

    • setCapacity: (maxSize: number) => void

      the default cache capacity of 500 items per cache

      General caching guidance:

      • 95% of the time, 500 works fine
      • For very large applications, up to 1000 is reasonable
      • For smaller apps, dropping down to 100 - 250 may save memory

      Ultimately the impact will be minimal unless your app has very specific rendering needs.

    Accessors

    • get compiled(): CompiledTemplate

      Returns CompiledTemplate

    • get notationMap(): Map<string, NotationAccessor>

      Returns Map<string, NotationAccessor>

    Methods

    • Create a full copy of this template for use in rendering to another root

      Returns Template

    • Returns HTMLTemplateElement

      An HTMLTemplateElement representing this template

    • Parameters

      Returns void

    • Parameters

      • value: unknown

      Returns value is Template