Skip to content

How to pass attrs filled with context of the parent #44

Closed Answered by jpsca
kamcio181 asked this question in Q&A
Discussion options

You must be logged in to vote

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:

{% call catalog.irender("Buttons.Button", hx_delete="/merge/file/{{ file.id }}")
Label
{%- endcall %}

which is invalid.
The solution is to use something like <Buttons.Button hx-delete={"/merge/file/" + file.id }>

which is compiled to

{% call catalog.irender("Buttons.Button", hx_delete="/merge/file" + file.id)
Label
{%- endcall %}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jpsca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants