Framework: Bootstrap Block Templates#3668
Conversation
7a8ded7 to
64ab4db
Compare
Codecov Report
@@ Coverage Diff @@
## master #3668 +/- ##
=========================================
- Coverage 37.32% 37.3% -0.02%
=========================================
Files 277 277
Lines 6685 6690 +5
Branches 1213 1214 +1
=========================================
+ Hits 2495 2496 +1
- Misses 3532 3536 +4
Partials 658 658
Continue to review full report at Codecov.
|
editor/effects.js
Outdated
There was a problem hiding this comment.
Are we sure we are going to want additional properties on the template object instead of making template = template.blocks?
There was a problem hiding this comment.
I don't know honestly. Server-side I think so, because templates could have a name/description but client-side I don't really know. I thought we should do this to avoid future breaking changes.
There was a problem hiding this comment.
Yes, just thinking out-loud. There are things like "locking" which might be interesting there. Not sure about naming templates, but maybe an id / slug if they are stored somewhere?
There was a problem hiding this comment.
Thinking further, I can't see why we would pair defining blocks and naming in the CPT. If anything, the "template" would be defined outside the CPT and referenced here by slug.
Also, things like locking could be defined as another attribute of the CPT registration, which seems more in line with how we generally structure options:
'template' => array(
array( 'core/image' ),
array( 'core/paragraph', array(
'placeholder' => 'Add a book description',
) ),
array( 'core/quote' ),
),
'template_lock' => true,Finally, what do you think of simplifying the syntax to not require name => 'core/heading'? I think we can rely on the definition of a block to be array( blockName, attributes ... ).
There was a problem hiding this comment.
Sure, I was not sure about the extra keys anyway.
editor/effects.js
Outdated
There was a problem hiding this comment.
I love that this fairly low profile implementation wise.
64ab4db to
55454fe
Compare
|
This is looking good to me. We probably want to add a test and some documentation. I think we might need a new "Templates" document. (Doesn't have to block this.) |
|
Merged, let's add the docs and tests separately. |
| ); | ||
|
|
||
| $post_type_object = get_post_type_object( $post_to_edit['type'] ); | ||
| if ( $post_type_object->template ) { |
There was a problem hiding this comment.
Notice: Undefined property: WP_Post_Type::$template in /srv/www/editor/htdocs/wp-content/plugins/gutenberg/lib/client-assets.php on line 786
I suggest running with high error reporting:
error_reporting( E_ALL );
(Add near top of site root index.php)
There was a problem hiding this comment.
You want empty here:
if ( ! empty( $post_type_object->template ) ) {|
I'm not sure if this is intended, but omitting |
|
@iamhexcoder Yes, this is expected. Gutenberg uses the REST API and if the We'll figure out a way to solve this. Tracked in #3066 |
This PR is the first one introducing the Block Templates. (details on those here #3588 )
This first iteration allows:
A template object looks like this:
Testing instructions
Notes