Hi,
I have a large project coming up.
I wanted to use fragments to mutualize code.
Basically I will have 6 instance of the same block all of them using the same code but with different parameters.
So using fragments looks like the way of doing it.
I saw a props parameter when loading a fragment, but I couldn't figure how to use it.
Is there some docs or something ?
Attached two files showing my attempt
Best
mainSample.json (1.5 KB)
fragmentSample.json (2.3 KB)
Hello,
Thanks for your answer.
I got it to work using a matrix.
A few pitfalls to avoid :
a fragment file should be saved with the fragment mode enabled to update
a fragment should have one panel under the root widget containing all the widget.
There is still something I don't get.
using the matrix, if the props are :
{
"file": "fragmentSample.json",
"props": { "variables": { "fragment_id": "test" } }
}
it works.
using a fragment, if the props are :
{
"props": { "variables": { "fragment_id": "test" } }
}
it doesn't work.
Is there something else to do with the fragment so it can update ?
Attached the updated files
fragmentSample.json (2.1 KB)
mainSample.json (3.0 KB)
best
In the case of a single fragment it should be
{
"variables": { "fragment_id": "test" }
}
Super works like a charm !
Thanks for the precision.
Attached the files for future use
fragmentSample.json (2.2 KB)
mainSample.json (1.5 KB)
Best
1 Like
Jason
April 10, 2024, 4:17am
6
Hi,
I would like to ask, can properties only be passed through variables? If the fragment widget's id or other properties is not a variable, is there a way to override it?
Any property can be overridden but it only affects the fragment's top level widget:
{
"id": "foo",
"colorWidget": "red",
"variables": {"a": 1, "b": 2}
}
Overriding the variable
property is a convenience to affect nested widgets in the fragment that would use @{parent.variables.a}
in their own properties.
1 Like
Jason
April 10, 2024, 6:53am
8
Thank you.
I found that it works if I save the fragment with the Save command, but it doesn't work if I use Export from the Session menu.