Skip to content

It'd be nice if could pass attrs from parent to child at compose time #14

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

You must be logged in to vote

You can! But it's barely mentioned in the docs :( (https://jinjax.scaletti.dev/guide/extra/#attrs-methods).

<Parent>
  <Child __attrs={attrs} />
  <Child />
</Parent>
  1. attrs are the parent attrs
  2. __attrs begins with two underscores

If you only want to pass some arguments (and you know which ones), you can do it like any other value (attrs is similar to a dict)

<Parent>
  <Child title={attrs.get('title') or 'Hello'} />
  <Child />
</Parent>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CiberNin
Comment options

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
3 participants
Converted from issue

This discussion was converted from issue #13 on May 06, 2023 02:39.