Example #1
0
 /**
  * Load from template.
  *
  * @param       $template
  * @param array $data
  * @param null  $engine
  *
  * @return mixed
  */
 public function loadTemplate($template, array $data = [], $engine = null)
 {
     // Init factory based on given engine, based on extension or use of default engine
     $factory = TemplateFactory::create($template, $engine);
     // Render the template
     $html = $factory->make($template, $data)->render();
     $this->addHtml($html);
     return $this;
 }
Example #2
0
 /**
  * Load from template.
  *
  * @param       $template
  * @param array $data
  * @param null  $engine
  *
  * @return mixed
  */
 public function loadTemplate($template, array $data = [], $engine = null)
 {
     // Init factory based on given engine, based on extension or use of default engine
     $factory = TemplateFactory::create($template, $engine);
     // Render the template
     $html = $factory->make($template, $data)->render();
     // Remove doctype, so drivers like PHPWord don't run into problems
     $html = preg_replace("/<!DOCTYPE [^>]+>/", '', $html);
     $this->addHtml($html, null, true);
     return $this;
 }
Example #3
0
 /**
  * Load from template.
  *
  * @param       $template
  * @param array $data
  * @param null  $engine
  *
  * @return mixed
  */
 public function loadTemplate($template, array $data = [], $engine = null)
 {
     // Init factory based on given engine, based on extension or use of default engine
     $factory = TemplateFactory::create($template, $engine);
     // Render the template
     $html = $factory->make($template, $data)->render();
     // Convert the html to a sheet
     (new HtmlToSheetConverter())->convert($html, $this);
     return $this;
 }