statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.08k stars 533 forks source link

Bard Field with antlers parsing outputs additional Paragraph Tags #10825

Open Jubeki opened 1 month ago

Jubeki commented 1 month ago

Bug description

If you use a globals with a Bard Field. And try to output it inside another Bard Field you get one additional paragraph tag before and after the globals output.

I would expect no additional tags before and after.

How to reproduce

https://github.com/Jubeki/statamic-bug-antlers-and-bard

Steps for setting up:

  1. Setup a fresh Statamic Application
  2. Add a Globals with a Bard Field and some content (Globals: contact, Bard Field: details)
  3. Use a Bard Field on the Page Collection, enable Antlers parsing and output the global {{ contact:details }}
  4. See on the homepage that before and after the global output are each one additional empty paragraph tag. (using the Dev Tools)

Changing the Remove Empty Nodes Option from Don't remove empty nodes to Remove empty nodes at start and end does not change the behaviour.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 11.23.5
PHP Version: 8.3.11
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: localhost:8000
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 0
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.25.0 Solo

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

duncanmcclean commented 1 month ago

Unfortunatley, I can't seem to reproduce this...

I cloned down your repository, enabled the "Antlers" setting on the details field and slimmed down the layout so the <body> is just {{ contact:details }}.

CleanShot 2024-09-24 at 10 53 56

Jubeki commented 1 month ago

Hey @duncanmcclean thanks for looking into it.

I also stripped down the repository now and the issue still occurs.

Strip Down Commit: https://github.com/Jubeki/statamic-bug-antlers-and-bard/commit/13241052935bf07a635889954d1f574590d9d9df

I also have deploy the same repository, without any changes (except enabling production mode and disabling debug) to https://statamic.kiekbjul.de

Where I also can see the same issue (Safari and Chrome):

Screenshot 2024-09-24 at 12 09 29
Jubeki commented 1 month ago

The problem lies within using {{ contact:details }} within another Bard Field (on the Homepage in this case) and not directly in a view.

duncanmcclean commented 1 month ago

The problem lies within using {{ contact:details }} within another Bard Field (on the Homepage in this case) and not directly in a view.

Oh, I see it now. Thanks!

Out of curiosity, why are you using Antlers inside a Bard's content, instead of using a Bard set?

Jubeki commented 1 month ago

I must say, I didn't really think about using a set for this, because I only thought about outputting the globals value like with antlers, and that was the simplest thing I could think of in that moment.

One of the main reasons may be: That I use the contact details in different contexts:

  1. Footer Globals, which has 3 Columns, each with a Bard Field
  2. Pages Collection, which has a Bard-Field as a Page-Builder and in there is a Cards-Set, where each Card also has a Bard-Field. So in one such a card the value is also used.
  3. Inside a view directly

So they are different Bard Fields and I would need to configure them accordingly.

(I will take down statamic.kiekbjul.de to prevent miss use)