websemantics / builder-extension

Scaffold your PyroCMS apps in style for a more pleasurable and productive coding experience.
https://github.com/pyrocms-templates
MIT License
12 stars 4 forks source link

String_loader is depreciated #30

Closed edster closed 6 years ago

edster commented 7 years ago

https://github.com/websemantics/builder-extension/pull/29

Pull request has an issue after this change. Not sure if unrelated but havn't been able to find a fix for it.

C:\Sites\martello_group\core\websemantics\builder-extension\src\Support\TwigParser.php
   * @param UrlGenerator $url
   * @param Engine       $parser
   * @param Request      $request
   */
  public function __construct()
  {
    $this->twig = new \Twig_Environment(new \Twig_Loader_Array());
    $this->twig->addExtension(new TwigExtension());
  }

  /**
   * Parse data into the content
   *
   * @param  string $content
   * @param  array $data
   * @return string
   */
  public function parse($content, $data = [])
  {
    return $this->twig->render($content, $data);
  }
}

Arguments
"Http"
array:7 [▶]
websemantics commented 7 years ago

Hi @edster and thanks for the PR,

Haven't been using the Builder / Pyro for quit awhile :/ ... However, looking into the link you provided it seems there's an extra step of creating a template that's missing,

So the parse function should now have

public function parse($content, $data = [])
  {
    $template = $env->createTemplate($content);
    return $this->twig->render($template, $data);
  }

I haven't tested this so be careful :)

edster commented 7 years ago

Thanks @websemantics, that got me farther along, I figured there was something missing there.

Ends up throwing Illegal offset type in isset or empty afterwards.

Not sure how this all works xD, might be a bug https://github.com/twigphp/Twig/issues/2546