Permalink
Browse files

implements real blocks

  • Loading branch information...
1 parent 52da6ce commit 3b84011e299b924c463b4bb659d75bc41083746e @shaunlee committed Sep 10, 2013
Showing with 12 additions and 4 deletions.
  1. +12 −4 ajoy/components/EasyView.php
@@ -6,7 +6,7 @@ class EasyView extends ViewHelper implements IAjoyView
/**
*
*/
- private $context = array();
+ private $blocks = array();
/**
*
@@ -50,14 +50,22 @@ public function extending($layout)
public function block($variable)
{
array_push($this->variables, $variable);
+ if (!isset($this->blocks[$variable])) {
+ $this->blocks[$variable] = array();
+ }
ob_start();
}
public function endblock()
{
$ctx = ob_get_clean();
+
$variable = array_pop($this->variables);
- $this->context[$variable] = $ctx;
+ array_push($this->blocks[$variable], $ctx);
+
+ if (empty($this->layouts)) {
+ echo array_shift($this->blocks[$variable]);
+ }
}
private function renderFile($filename, $fn)
@@ -93,7 +101,7 @@ public function render($template, array $context = array(), $return = false)
$ctx = $this->render($layout, array(), true);
}
return $ctx;
- }, app()->locals(), $this->context, $context));
+ }, app()->locals(), $context));
if ($return)
return $ctx;
@@ -110,7 +118,7 @@ public function renderPartial($template, array $context = array(), $return = fal
app()->raise('Views file with name "' . $this->viewsPath . '/' . $template . '.php" does not exists.');
$ctx = call_user_func_array(array($this, 'renderFile'),
- array($filename, null, app()->locals(), $this->context, $context));
+ array($filename, null, app()->locals(), $context));
if ($return)
return $ctx;

0 comments on commit 3b84011

Please sign in to comment.