Skip to content
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

Add an option to choose whether or not to render the Template Part wrapper #53760

Open
alexandrebuffet opened this issue Aug 17, 2023 · 1 comment
Labels
[Block] Template Part Affects the Template Parts Block [Type] Enhancement A suggestion for improvement.

Comments

@alexandrebuffet
Copy link
Contributor

alexandrebuffet commented Aug 17, 2023

What problem does this address?

The block Template Part renders a wrapper element which is not always necessary.

For example, I have a Block Theme where I'd like to display a block that handles the display of the site header inside my Header template part. My block already handles everything (tag name, style and markup options...) and I'd like to get rid of the unnecessary <div> (or any other tag chosen) provided by the Template Part block.

What is your proposed solution?

I think it would be interesting to be able to choose not to render the wrapper and just display the content inside with an option in the admin and a condition in the block render.

In addition, the block_template_part() function (useful in Hybrid Theme) only displays the content inside a Template Part, without the wrapper div. I find this confuses the overall use of Template Parts.

@jordesign jordesign added [Type] Enhancement A suggestion for improvement. [Block] Template Part Affects the Template Parts Block labels Aug 18, 2023
@eric-michel
Copy link

eric-michel commented May 16, 2024

Just ran into this issue today as well. I needed to split two elements in my header template part so that I could have the lower nav be position: sticky, but because of the wrapper element, I had to create two fully separate template parts and modify every template instead.

This came up previously but, at the time, there was no solution because the editor needed the wrapper, and keeping things consistent between the editor and the frontend required the wrapper to exist in both places: #36853.

Things have changed since then; blocks like synced patterns manage to offer this functionality just fine. It would be incredibly useful to have the flexibility to turn off the wrapper entirely for template parts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Template Part Affects the Template Parts Block [Type] Enhancement A suggestion for improvement.
3 participants