diff --git a/docs/en/docs/syntax/overview.md b/docs/en/docs/syntax/overview.md index 1bfb01f..95b9c69 100644 --- a/docs/en/docs/syntax/overview.md +++ b/docs/en/docs/syntax/overview.md @@ -5,6 +5,7 @@ - `<% %>`: Inline tag, you can write Rust code inside this tag - `<%= %>`: Evaluate the Rust expression and outputs the value into the template (HTML escaped) - `<%- %>`: Evaluate the Rust expression and outputs the unescaped value into the template +- `<%+ %>`: Evaluate the Rust expression producing a `TemplateOnce` value, and render that value into the template - `<%# %>`: Comment tag - `<%%`: Outputs a literal '<%' diff --git a/docs/en/docs/syntax/tags.md b/docs/en/docs/syntax/tags.md index c298228..830c84d 100644 --- a/docs/en/docs/syntax/tags.md +++ b/docs/en/docs/syntax/tags.md @@ -105,3 +105,30 @@ If you want to render the results without escaping, you can use `<%- %>` tag or ``` rhtml <% let result = %><%= 1 %><% ; %> ``` + +## Component block + +Rust expression inside `<%+ %>` tag is evaluated and then rendered by +calling its `render_once()` method. If the value does not have an +appropriate method, a compile-time error will be reported. + +This makes it easy to use types which are `TemplateOnce` as components +which can be embedded into other templates. + +=== "Template A" + + ``` rhtml + A <%= val %> + ``` + +=== "Template B" + + ``` rhtml + B <%+ A { val: "example" } %> + ``` + +=== "Result" + + ``` text + B A example + ```