-
Hello Guys I have a Button.jinja
I want to use the component like below, so I want to pass file attribute to the parent component and use it on the child
Unfortunately in generated component I can see that file.id has not been replaced with the value: Is that something that is supported but I am doing it in wrong way or this is something that is not supported? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
tl;dr: Do this instead: Yes, the component attributes can't work with Jinja code directly. That is because a component is converted to a macro before rendering, so what you were trying to do becomes: {% call catalog.irender("Buttons.Button", hx_delete="/merge/file/{{ file.id }}")
Label
{%- endcall %} which is invalid. which is compiled to {% call catalog.irender("Buttons.Button", hx_delete="/merge/file" + file.id)
Label
{%- endcall %} |
Beta Was this translation helpful? Give feedback.
tl;dr: Do this instead:
<Buttons.Button hx-delete={"/merge/file/" + file.id }>
Yes, the component attributes can't work with Jinja code directly. That is because a component is converted to a macro before rendering, so what you were trying to do becomes:
which is invalid.
The solution is to use something like
<Buttons.Button hx-delete={"/merge/file/" + file.id }>
which is compiled to