Skip to content

feat: support function as options.template#568

Merged
arturovt merged 1 commit intomasterfrom
feat/options-template
Feb 25, 2026
Merged

feat: support function as options.template#568
arturovt merged 1 commit intomasterfrom
feat/options-template

Conversation

@arturovt
Copy link
Member

Allow template to accept a function (props: AppProps) => string in addition to a plain string. This enables dynamic template generation based on single-spa props at mount time.

  • Update BaseSingleSpaAngularOptions type to accept string | ((props: AppProps) => string)
  • Call the function with props in getContainerElementAndSetTemplate if template is a function
  • Update validation error message in singleSpaAngular to reflect both accepted types
  • Update navbar example app to use the new function form

Allow `template` to accept a function `(props: AppProps) => string` in
addition to a plain string. This enables dynamic template generation
based on single-spa props at mount time.

- Update `BaseSingleSpaAngularOptions` type to accept `string | ((props: AppProps) => string)`
- Call the function with `props` in `getContainerElementAndSetTemplate` if `template` is a function
- Update validation error message in `singleSpaAngular` to reflect both accepted types
- Update navbar example app to use the new function form
@arturovt arturovt merged commit 2b7656b into master Feb 25, 2026
1 check failed
@arturovt arturovt deleted the feat/options-template branch February 25, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant