mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Working on twig
This commit is contained in:
parent
8256131ea2
commit
eaad980f1e
@ -74,6 +74,28 @@ class PdfMaker
|
|||||||
$this->updateElementProperties($this->data['template']);
|
$this->updateElementProperties($this->data['template']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isset($this->data['template'])) {
|
||||||
|
$contents= $this->document->getElementsByTagName('twig');
|
||||||
|
|
||||||
|
foreach ($contents as $content) {
|
||||||
|
|
||||||
|
$template = $content->ownerDocument->saveHTML($content);
|
||||||
|
|
||||||
|
$loader = new \Twig\Loader\FilesystemLoader(storage_path());
|
||||||
|
$twig = new \Twig\Environment($loader);
|
||||||
|
$template = $twig->createTemplate($template);
|
||||||
|
$template = $template->render([
|
||||||
|
'invoice' => \App\Models\Invoice::first()->toArray(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$f = $this->document->createDocumentFragment();
|
||||||
|
$f->appendXML($template);
|
||||||
|
|
||||||
|
$content->parentNode->replaceChild($f, $content);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($this->data['variables'])) {
|
if (isset($this->data['variables'])) {
|
||||||
$this->updateVariables($this->data['variables']);
|
$this->updateVariables($this->data['variables']);
|
||||||
}
|
}
|
||||||
@ -89,8 +111,9 @@ class PdfMaker
|
|||||||
*/
|
*/
|
||||||
public function getCompiledHTML($final = false)
|
public function getCompiledHTML($final = false)
|
||||||
{
|
{
|
||||||
$html = $this->document->saveHTML();
|
|
||||||
|
|
||||||
|
$html = $this->document->saveHTML();
|
||||||
|
nlog($html);
|
||||||
return str_replace('%24', '$', $html);
|
return str_replace('%24', '$', $html);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user