-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Inline Dynamic Content Solutions #21932
Copy link
Copy link
Closed as duplicate
Labels
Needs Technical FeedbackNeeds testing from a developer perspective.Needs testing from a developer perspective.[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.Questions or issues with incorporating or styling blocks in a theme.[Type] DiscussionFor issues that are high-level and not yet ready to implement.For issues that are high-level and not yet ready to implement.
Metadata
Metadata
Assignees
Labels
Needs Technical FeedbackNeeds testing from a developer perspective.Needs testing from a developer perspective.[Feature] Block APIAPI that allows to express the block paradigm.API that allows to express the block paradigm.[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.Questions or issues with incorporating or styling blocks in a theme.[Type] DiscussionFor issues that are high-level and not yet ready to implement.For issues that are high-level and not yet ready to implement.
Type
Fields
Give feedbackNo fields configured for issues without a type.
We need to decide on how we are going to handle inline dynamic content in blocks. (Things like base URLs of template images and translatable strings.)
It kind of breaks our current FSE template solution if we can’t find a solution for this.
Proposal
I still think some kind of inline token/block is the worthiest option to explore right now.
I know there are concerns about having demarcations inside elements because that would make the HTML “invalid”. Still, because of the nature of React, at worst, these inline demarcations will be inside attribute values, and that would always be valid markup. Although, I would argue that if you are viewing a document without server rendering, you wouldn’t want blocks that depend on inline dynamic content to render at all, just like how dynamic blocks work.
I proposed a way of doing that in this comment. Blocks that have inline dynamic content are entirely commented out in the markup and only uncommented by the server renderer if it can resolve all of its inline tokens. For things like translatable text, a “default” uncommented block can be on top with the inline tokens resolved to their default values. When server rendering, the renderer can delete that default block and replace it with the commented out one, with its inline tokens resolved.
Some examples:
Base URL
Static
Rendered
I18N
Static
Rendered
With this, we can do everything we like about blocks, at the inline-level. For example, we can use the inline token attributes to have specific, local base URL settings, or, have different localization settings for different pieces of text, or none at all.
Alternatives?
I think this is a critical issue/decision, and we should all think about it deeply. I am looking forward to hearing your thoughts, alternative proposals, and feedback.