Exemple #1
0
 /**
  * Validate the template.
  *
  * @param string $template Twig template.
  * @param string $file     Filename of the template.
  *
  * @return array
  */
 protected function validate($template, $file = null)
 {
     try {
         $this->twig->parse($this->twig->tokenize($template, $file));
     } catch (Twig_Error $e) {
         return ['template' => $template, 'file' => $file, 'valid' => false, 'exception' => $e];
     }
     return ['template' => $template, 'file' => $file, 'valid' => true];
 }
 /**
  * Compiles an incident template into an incident message.
  *
  * @param string $templateSlug
  * @param array  $vars
  *
  * @return string
  */
 protected function parseIncidentTemplate($templateSlug, $vars)
 {
     if ($vars === null) {
         $vars = [];
     }
     $this->twig->setLoader(new Twig_Loader_String());
     $template = IncidentTemplate::forSlug($templateSlug)->first();
     return $this->twig->render($template->template, $vars);
 }
 /**
  * Handle the command.
  *
  * @param Bridge     $twig
  * @param Filesystem $files
  */
 public function handle(Bridge $twig, Filesystem $files)
 {
     $files->deleteDirectory($twig->getCache());
 }
 /**
  * Handle the event.
  */
 public function handle()
 {
     $this->twig->addExtension($this->container->make('Anomaly\\PreferencesModule\\PreferencesModulePlugin'));
 }
Exemple #5
0
 /**
  * Renders a route with variables
  *
  * @param string $name
  * @param array $context
  * @return bool|string
  */
 public function render($name, array $context = array())
 {
     $view = $this->getViewName($name, false);
     return parent::render($view, $context);
 }