-
Notifications
You must be signed in to change notification settings - Fork 11
Tracking Issue: Server-side rendering of directives #120
Comments
Iβll stop working on the server-side rendering of directives for now since weβre shifting our focus to other priorities. Overall, the Tag Processor has proven to be a good fit for this, and weβve successfully implemented SSR for a number of directives. Weβre still having some issues with |
|
|
I'm not sure I see this as violating any separation of concern issues, particularly since a directive handler might want to add or remove from that list (i.e. remove itself). Still, this is not a concern that has to be exposed. It would be a choice to make, but it's just as easy to pass the recursion into the function itself as a closure encapsulating any general state. $recurse = function( $tags, $prefix, $context ) use ( $directives ) {
return wp_process_directives( $tags, $prefix, $directives, $context );
};
process_wp_each( $tags, $context, $recurse );
function process_wp_each( $tags, $context, $process_recursively ) {
β¦
$inner_html = $tags->get_inner_html();
$inner_tags = new WP_Directive_Processor( $inner_html );
$inner_tags = $process_recursively( $inner_tags, 'data-wp-', $context );
$loop_inner_html .= $inner_tags->get_updated_html();
$context->rewind_context();
β¦
}
I'm probably missing something, but this doesn't seem like it'd require too much state tracking. Would be curious where you see this causing more hassle specifically.
Hm. That seems clever π€ |
I think I'd rather isolate them from each other (and generally isolate the directives from the processing loop or recursion). I don't see the immediate need to allow them to add or remove other handlers (or even themselves) to or from that list, respectively, so I'd prefer to go with YAGNI π¬
That's fair, thank you for bringing that up!
I meant option 2.ii (not 2.i) -- apologies if that caused any confusion:
As for the problem with 2.ii, I'll try to explain in pseudo code. Let's go with the example markup from above. Here's a naive first iteration:
But this is where it gets tricky. We can now jump back to the opening tag, but we'll need to make sure that next time we set But there's another, bigger, problem: We've already processed the markup that's enclosed in the tag with the
Thank you! Not sure I can take credit for it, I think it was @luisherranz' idea π Since it makes things more explicit and easier to reason about than what I described above, it's quickly becoming my preferred approach. |
I'm going to close this issue as part of the migration to the Gutenberg repository. These tasks were added to the Roadmap and we'll reopen an issue/discussion once it's time to start working on this again. Also, this is the current Tracking Issue on Gutenberg. |
Based on #118 (comment) and #125.
β - Implemented
π‘ - Waiting for an upcoming Gutenberg release to include a missing feature
β - Blocked by missing feature in
WP_HTML_Tag_Processor
wp-context
wp-show
get_content_inside_balanced_tags()
from WordPress/gutenberg#46345, and a matchingset_content_inside_balanced_tags()
(see WordPress/gutenberg#47036).wp-bind
get_attribute_names_with_prefix()
; landed in GB 15.0wp-class
wp-bind
.wp-style
wp-bind
. Furthermore, see WordPress/gutenberg#46887. (The latter isn't a blocker, though.)wp-text
wp-show
.wp-for
/wp-each
wp-html
wp-show
.wp-slot
&wp-fill
TODO:
when
.context.myblock.open
).register_directive
, takes a directory with adirective.json
which includes information such asattributes
,render
, context, ...?The text was updated successfully, but these errors were encountered: