public function render($name, $params = [])
 {
     $params = $this->mergeParams($name, $params);
     $template = $this->resolver->resolve($name);
     if (!$template) {
         throw new Exception\TemplateNotFoundException("Couldn't resolve '{$name}'");
     }
     if ($template->isCompiled()) {
         $compiled = (string) $template;
     } else {
         try {
             $compiled = $this->handlebars->precompile((string) $template);
         } catch (\V8JsScriptException $e) {
             throw new Exception\TemplateCompilationException("Error compiling '{$name}'", 0, $e);
         }
         if ($this->resolver instanceof SavingResolverInterface) {
             $this->resolver->save($template->getKey(), $compiled);
         }
     }
     try {
         $template = $this->handlebars->template($compiled);
         return $template($params);
     } catch (\V8JsScriptException $e) {
         throw new Exception\TemplateExecutionException("Error running '{$name}'", 0, $e);
     }
 }
 private function injectJsHelpers(ResolverInterface $resolver, Handlebars $handlebars, $helpers)
 {
     foreach ($helpers as $fileName) {
         $helper = $resolver->resolve(self::NS . '::' . $fileName);
         if (!$helper) {
             $helper = @file_get_contents($fileName);
             if (!$helper) {
                 throw new Exception\HelperNotFoundException("Couldn't load helper from '{$fileName}'");
             }
             if ($resolver instanceof SavingResolverInterface) {
                 $resolver->save(self::NS . '::' . $fileName, $helper);
             }
         }
         $handlebars->registerHelper($this->getName($fileName), $helper);
     }
 }