Skip to content

Commit

Permalink
Framework: Support nested templates
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Feb 20, 2018
1 parent da8184a commit 76d2ec0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions editor/store/effects.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,16 @@ export default {
if ( post.content.raw ) {
blocks = parse( post.content.raw );
} else if ( settings.template ) {
blocks = map( settings.template, ( [ name, attributes ] ) => {
const block = createBlock( name );
block.attributes = {
...block.attributes,
...attributes,
};
return block;
} );
const createBlocksFromTemplate = ( template ) => {
return map( template, ( [ name, attributes, innerBlocksTemplate ] ) => {
return createBlock(
name,
attributes,
createBlocksFromTemplate( innerBlocksTemplate )
);
} );
};
blocks = createBlocksFromTemplate( settings.template );
} else {
blocks = [];
}
Expand Down

0 comments on commit 76d2ec0

Please sign in to comment.