Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Commit

Permalink
allowing more table-row types in TemplateRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
juzna committed Mar 7, 2011
1 parent 517a714 commit d45ce96
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/classes/tables2/Creators/TemplateRenderer.php
Expand Up @@ -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
Expand Down

0 comments on commit d45ce96

Please sign in to comment.