Skip to content

v3.5.0 - Syntax aware templates

Choose a tag to compare

@localnerve localnerve released this 08 Sep 13:52
· 21 commits to main since this release
9c49259

v3.5.0

Highlights

  • Syntax-aware template injection. CSS/HTML/link markup is now injected into the
    component's JavaScript via an acorn parse + quote-context-aware splice
    (lib/replace.js) instead of brittle text replacement with a per-line backslash hack.
    Injected markup may now safely contain ', ", `, ${, and backslashes without
    corrupting the surrounding JS.
  • Multiple templates. A component can now define several HTML templates (e.g. default /
    error / empty states), each with its own token, via the new templates option. Shared
    cssPath/cssLinkHref are applied to every template; a template may override its own
    cssLinkHref.
  • Result exposes htmls. An ordered array of { name, path, getHtml }, one per
    template. The existing getHtml() / htmlPath shorthands now resolve to the first
    html output and remain for backward compatibility.
  • Output-collision fix. Duplicate resolved html output names now throw instead of
    silently overwriting each other (previously all templates shared <basename>.html).

Backward compatibility

Non-breaking. The flat htmlPath + jsReplacement options continue to work and are
synthesized into a single template internally. All existing fixtures pass unmodified.

New dependency

  • acorn — JavaScript parser used for token location and safe injection.

Migration notes

None required for v3.4.x callers. To adopt multi-template, pass a templates array; see
docs/v3.5.0.md.

What's Changed

  • @3.5.0 - syntax aware templates, multiple outputs by @localnerve in #77

Full Changelog: v3.4.2...v3.5.0