Skip to content
Browse files

allowing more table-row types in TemplateRenderer

  • Loading branch information...
1 parent 517a714 commit d45ce96e34d73619219bb0213c383d3ea589979d @juzna committed Mar 7, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 app/classes/tables2/Creators/TemplateRenderer.php
View
9 app/classes/tables2/Creators/TemplateRenderer.php
@@ -55,14 +55,21 @@ protected function getTemplate() {
$tpl = new \Nette\Templates\FileTemplate($path);
$tpl->registerFilter(new \Nette\Templates\LatteFilter);
$tpl->parameters = '';
- $tpl->dataSource = $this->getDatasource();
+ $tpl->dataSource = $this->unifyDataSource($this->getDatasource());
// Assign variables
if($this->templateVariables) foreach($this->templateVariables as $k => $v) $tpl->$k = $v;
return $tpl;
}
+ // TODO: replace this function with callback iterator or calls to Renderer->getFieldValue() in code
+ protected function unifyDataSource($ds) {
+ $ret = array();
+ foreach($ds as $key => $item) $ret[$key] = is_array($item) ? (object) $item : $item;
+ return $ret;
+ }
+
/**
* Generate template code and store it to file
* @param string $path Path to store template code

0 comments on commit d45ce96

Please sign in to comment.
Something went wrong with that request. Please try again.