-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
Bard: Object instead of array with raw modifier #11254
Comments
That is wrong, was too late yesterday. Of course every block element should have it's own array with a type of array:1 [▼ // vendor/statamic/cms/src/Modifiers/CoreModifiers.php:622
0 => array:3 [▼
"type" => "heading"
"attrs" => array:2 [▼
"textAlign" => "left"
"level" => 2
]
"content" => array:3 [▼
0 => array:2 [▼
"type" => "text"
"text" => "Sorgenfrei zur Schadensregulierung – Unfallgutachten von Gutachterix für mehr Entschädigung"
]
]
]
1 => array:3 [▼
"type" => "heading"
"attrs" => array:2 [▼
"textAlign" => "left"
"level" => 3
]
"content" => array:3 [▼
0 => array:2 [▼
"type" => "text"
"text" => "100% kostenlos für Unfallgeschädigte"
]
]
]
2 => array:3 [▼
"type" => "paragraph"
"attrs" => array:2 [▼
"textAlign" => "left"
"class" => null
]
"content" => array:3 [▼
0 => array:2 [▼
"type" => "text"
"text" => "Waren Sie in ..."
]
]
]
] |
This seems to be an edge case where I need to append I have an accordion partial (WIP): <div x-data="{
id: {{ index }},
get expanded() {
return this.active === this.id
},
set expanded(value) {
this.active = value ? this.id : null
},
}" role="region" class="grid {{ view:class }}">
{{ slot:image }}
<div class="flex items-center {{ up ? 'flex-col-reverse' : 'flex-col' }}">
<button
type="button"
x-on:click="expanded = !expanded"
:aria-expanded="expanded"
>
{{ if slot:button }}
{{ slot:button }}
{{ else }}
<span x-show="!expanded">{{ accordion:button_open }}</span>
<span x-show="expanded">{{ accordion:button_close }}</span>
{{ /if }}
</button>
{{ partial:typography/richtext richtext="{accordion:richtext|raw or richtext|raw}" x-show="expanded" x-collapse="" }}
</div>
</div> As you can see, the {{ partial:typography/prose :$as :class="view:class" :when="richtext" }}
{{ foreach :array="richtext|raw" }}
<!-- do stuff -->
{{ /foreach }}
{{ /partial:typography/prose }} |
How is your accordion setup? Can you provide the YAML for the accordion field(s)? |
@duncanmcclean Sure, it just imports the fieldsets: title: Akkordeon
fields:
-
import: button_group
-
import: richtext |
Sorry, I'm not sure I completley understand your issue / how you have things setup (there's lots of partials / fieldsets going on here 😅).... Are you able to create a fresh Statamic site which clearly demonstrates your issue? 🙂 |
I think I got it. Explicitly passing a param vs. using the cascade seems to be the issue. Unfortunately i don't have the time to create a fresh installation for the reproduction, but you can see the issue here: https://github.com/gutacht/statamic/tree/bard I have prepared Accordion, lines 40 and 41:
Richtext also has a When you visit the home page, you will find the dump output at the top. Open the fourth and fifth array: You should see a different structure: The first one of the dump output before passing the contents to the richtext partial and the second one inside the richtext partial. If you change line 41 of the accordion partial and add a
Richtext is also used in the partial
When you add Add Conclusion Using a param with the cascade produces the array structure below with each Bard element in a separate array. But passing the Bard content explicitly to a partial, produces an array that contains a I hope the issue is clear now. 😄 |
Bug description
I have a Bard field with a pretty basic structure: h2, h3, p, h3, p, ... (see saved content as markdown at the end)
Using
{{ richtext|raw|dump }}
outputs an array with the following structure for each other Bard field where I have only one block element (maybe with ahardBreak
):But for this special field with more than one block element, the following is returned:
I expect the same structure as for the other Bard fields – with each block element as a separate array in
content
.The full markdown content of said field (correct structure):
How to reproduce
Use more than one block element in Bard and dump the raw data with {{ bard_field|raw|dump }}.
My fieldset config:
Logs
No response
Environment
Installation
Starter Kit using via CLI
Additional details
No response
The text was updated successfully, but these errors were encountered: