import Promise from "../utils/promise" ; param { string } content return { Object } function replaceBlocks ( content , blocks ) { const newContent = content . replace ( /\{\{\-\%([\s\S]+?)\%\-\}\}/g , ( match , key ) => { let replacedWith = match ; const block = blocks . get ( key ) ; if ( block ) { replacedWith = replaceBlocks ( block . get ( "body" ) , blocks ) ; } return replacedWith ; } ) ; return newContent ; } param { TemplateEngine } engine param { TemplateOutput } content return { Promise < String > } function postRender ( engine , output ) { const content = output . getContent ( ) ; const blocks = output . getBlocks ( ) ; const result = replaceBlocks ( content , blocks ) ; return Promise . forEach ( blocks , ( block ) => { const post = block . get ( "post" ) ; if ( ! post ) { return ; } return post ( ) ; } ) . thenResolve ( result ) ; } export default postRender ;