Skip to content

Qute: include - make it possible to supply the template id dynamically #48433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/src/main/asciidoc/qute-reference.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,15 @@ This section can be used to include another template and possibly override some
<1> Include a template with id `foo`. The included template can reference data from the current context.
<2> It's also possible to define optional parameters that can be used in the included template.

By default, the first unnamed parameter represents the id of a template that should be included.
And it is taken as is.
For example, `{#include bar/foo /}` includes a template with id `bar/foo`; i.e. `src/main/resources/templates/bar/foo.html` could be matched.
However, it is also possible to supply the template id dynamically.
Just add the `_dynamic=true` or `_dynamic` argument to the tag.
In this case, the first unnamed parameter represents an expression that is resolved and the result represents the template id.
For example, `{#include bar.foo _dynamic /}` means that `bar.foo` is first resolved and then the resulting template id is used.


_Template inheritance_ makes it possible to reuse template layouts.

.Template "base"
Expand Down
Loading
Loading