You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Preserve static attribute raw values, keep omitted-state behavior explicit, and use entry-template WASM rendering in the CLI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The `*_without_state` APIs render with an empty object root state. In WASM, the state parameter is optional for `render`and `render_with_templates`; omitted state also uses an empty object. `render_with_templates` accepts an `attribute_name_strategy` string parameter (`""`, `"none"`, or `"camelCase"`):
305
+
The `*_without_state` APIs render with an empty object root state. In WASM, the state parameter is optional for `render`, `render_with_templates`, and `render_entry_with_templates`; omitted state also uses an empty object. The template-rendering WASM exports accept an `attribute_name_strategy` string parameter (`""`, `"none"`, or `"camelCase"`):
`wasm.rs` is compiled only for the `wasm32-unknown-unknown` target (`#[cfg(target_arch = "wasm32")]`). It exposes three functions to JavaScript via `wasm-bindgen`:
465
+
`wasm.rs` is compiled only for the `wasm32-unknown-unknown` target (`#[cfg(target_arch = "wasm32")]`). It exposes four functions to JavaScript via `wasm-bindgen`:
465
466
466
467
| Export | Signature | Description |
467
468
|--------|-----------|-------------|
468
469
|`render`|`(entry: &str, state?: string) → String`| Render a template with no custom elements; omitted state is `{}`|
469
-
|`render_with_templates`|`(entry: &str, templates_json: &str, state?: string, attribute_name_strategy?: string) → String`| Render top-level entry HTML with a pre-built `{name: content}` templates map; omitted state is `{}`|
470
+
|`render_with_templates`|`(entry: &str, templates_json: &str, state?: string, attribute_name_strategy?: string) → String`| Render a template with a pre-built `{name: content}` templates map using non-entry semantics; omitted state is `{}`|
471
+
|`render_entry_with_templates`|`(entry: &str, templates_json: &str, state?: string, attribute_name_strategy?: string) → String`| Render top-level entry HTML with a pre-built `{name: content}` templates map; omitted state is `{}`|
470
472
|`parse_f_templates`|`(html: &str) → String`| Parse `<f-template>` elements and return a JSON array |
471
473
472
474
### `parse_f_templates`
@@ -484,7 +486,11 @@ Calls `locator::parse_f_templates` (the same function used by `Locator::from_pat
484
486
485
487
### `render_with_templates`
486
488
487
-
Accepts `templates_json` as a JSON object string mapping element names to raw template strings (the inner content already extracted from `<template>`). Constructs a `Locator::from_templates` map and calls `render_entry_template_with_locator` when state is provided, or the no-state equivalent when it is omitted. Root-level custom elements therefore receive the full root state with HTML attributes overlaid, matching CLI entry rendering.
489
+
Accepts `templates_json` as a JSON object string mapping element names to raw template strings (the inner content already extracted from `<template>`). Constructs a `Locator::from_templates` map and calls `render_template_with_locator` when state is provided, or the no-state equivalent when it is omitted. This preserves the original non-entry semantics for existing JS consumers.
490
+
491
+
### `render_entry_with_templates`
492
+
493
+
Accepts the same arguments as `render_with_templates`, but calls `render_entry_template_with_locator` when state is provided, or the no-state equivalent when it is omitted. Root-level custom elements therefore receive entry opening-tag handling, matching CLI entry rendering.
Copy file name to clipboardExpand all lines: crates/microsoft-fast-build/README.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -510,14 +510,16 @@ let result = render_template_with_locator(
510
510
#### WASM / JavaScript API
511
511
512
512
```javascript
513
-
consthtml=render_with_templates(
513
+
consthtml=render_entry_with_templates(
514
514
entry,
515
515
templatesJson,
516
516
stateJson,
517
517
"camelCase"// or "none"
518
518
);
519
519
```
520
520
521
+
Use `render_with_templates` for the original non-entry template-rendering semantics; use `render_entry_with_templates` for top-level entry HTML rendering.
522
+
521
523
Passing `"none"` or `""` as the strategy uses the default behaviour.
0 commit comments