- Rewrites the rendering engine

- Updates tests
Closes #280
This commit is contained in:
Vlad
2016-01-01 15:42:34 -05:00
parent 5996696cc9
commit 2793e74858
17 changed files with 1099 additions and 888 deletions

View File

@ -1,11 +1,12 @@
<?php namespace MailPoet\Newsletter\Renderer\Blocks;
<?php
namespace MailPoet\Newsletter\Renderer\Blocks;
class Renderer {
function render($data) {
array_map(function ($block) use (&$blockContent, &$columns) {
$blockContent .= $this->createElementFromBlockType($block);
function render($data, $columnCount) {
array_map(function ($block) use (&$blockContent, &$columns, $columnCount) {
$blockContent .= $this->createElementFromBlockType($block, $columnCount);
if(isset($block['blocks'])) {
$blockContent = $this->render($block);
$blockContent = $this->render($block, $columnCount);
}
// vertical orientation denotes column container
if($block['type'] === 'container' && $block['orientation'] === 'vertical') {
@ -16,9 +17,9 @@ class Renderer {
return (isset($columns)) ? $columns : $blockContent;
}
function createElementFromBlockType($block) {
function createElementFromBlockType($block, $columnCount) {
$blockClass = __NAMESPACE__ . '\\' . ucfirst($block['type']);
return (class_exists($blockClass)) ? $blockClass::render($block) : '';
return (class_exists($blockClass)) ? $blockClass::render($block, $columnCount) : '';
}
}