Make WordPress Core

Opened 3 years ago

Closed 18 months ago

Last modified 17 months ago

#53148 closed feature request (fixed)

Blocks: Add new `render` property in `block.json` for block types

Reported by: gziolo's profile gziolo Owned by: gziolo's profile gziolo
Milestone: 6.1 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch has-unit-tests needs-dev-note
Focuses: Cc:

Description

See comment from @spacedmonkey on GitHub (https://github.com/WordPress/gutenberg/pull/13693#discussion_r287337504):

Current the render callback is a function call. How would it work as a file? Why not make it renderTemplate but still allow for renderCallback. Function calls, should be a method in a class or be namespaced, which wouldn't really work in another file.

ACF blocks, has a rendercallback / render template in it's block definitions.

There is also another thread started by @spacedmonkey in https://github.com/WordPress/gutenberg/pull/13693#discussion_r288121797 which expands on this topic.

Change History (9)

#1 @gziolo
3 years ago

  • Milestone changed from Future Release to Awaiting Review

#2 @gziolo
20 months ago

  • Owner set to gziolo
  • Status changed from new to assigned

I created a prototype in the Gutenberg plugin: https://github.com/WordPress/gutenberg/pull/42430.

#3 @gziolo
18 months ago

  • Keywords has-patch has-unit-tests added
  • Milestone changed from Awaiting Review to 6.1
  • Summary changed from Editor: Consider adding `renderTemplate` property for block types to Blocks: Add new `render` property in `block.json` for block types

#5 @gziolo
18 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 54132:

Blocks: Add new render property in block.json for block types

New render field in block.json file that accepts a string value. It allows to pass a path to the PHP file that is going to be used to render the block on the server. Related PR in Gutenberg: https://github.com/WordPress/gutenberg/pull/42430.

Props spacedmonkey, luisherranz, welcher, noisysocks, matveb, fabiankaegy, aristath, zieladam.
Fixes #53148.

#7 @SergeyBiryukov
18 months ago

FWIW, I think core generally does not include DocBlocks for anonymous functions like the one added in [54132], but I don't see any issues with that at a glance. I guess it won't be displayed in the WordPress Developer Reference, just hope it does not break the parser :)

#8 @gziolo
17 months ago

I hope it doesn't break. Would it help if we add an additional PHPDoc keyword like @internal?

#9 @milana_cap
17 months ago

  • Keywords needs-dev-note added
Note: See TracTickets for help on using tickets.