Feature #363

add support for sf 2 twig template

Added by raine ng 4 months ago. Updated 3 months ago.

Status:Resolved Start:01/{{count}}/2012
Priority:Low Due Date::
Assigned to:- % Done:

0%

Category:Plugins
Target version:0.9.14

Description

Associated revisions

Revision 6f4c47a1f1f182a7d49b52d029309b5e85e938f6
Added by Martin Rademacher 4 months ago

refs #363: add sf2 template engine implementation for ZenMagick PHP templates (still inactive)

Revision 503ec191eb03410f060ba99f805994c9c6d3e43b
Added by Martin Rademacher 4 months ago

refs #363: allow multiple engines, fix wrong variable name

Revision aa3677501d1ec83f8c5f36face3819e2ba338852
Added by Martin Rademacher 4 months ago

refs #363: implement more loader/locator that use the ZenMagick ResourceResolver and get basic twig working

Revision 93248569794792214d67e20503de1f32a1ffc89f
Added by Martin Rademacher 4 months ago

refs #363,#377:

  • big cleanup of view classes
  • drop type parameters
  • refactor ViewCache to TemplateCache
  • drop compiler option in View
  • drop ViewFilter

    - make ZMPhpEngine also handle .js files to allow PHP in js files

Revision 9708475c558df31fa41acb7160e6ac65bdb7e961
Added by Martin Rademacher 4 months ago

refs #363:

  • cleanup View methods (more to be done)
  • move methods from View into ZMPhpEngine that do not belong in View
  • change Widget interface to reflect the interface changes
  • rename View TemplateView and make View a base interface

Revision a942f1f03170183b3d6fb04457cf213e99e31297
Added by Martin Rademacher 4 months ago

refs #363: rename service id 'view' to 'templateView'

History

Updated by Martin Rademacher 4 months ago

  • Category set to Plugins
  • Target version set to 1.0

Updated by Martin Rademacher 4 months ago

  • Status changed from New to In Progress
  • added twig to bin/vendors.php
  • added twig to classloader (note: this is using the ZM loader via classloader.ini, not twigs autoloader)
  • added sf2 Templating and TwigBundle to classloader

This should be enough to get keen people started experimenting, This, for example, works nicely in my local.php (which I use as scatchpad..)

$loader = new Twig_Loader_String();
$twig = new Twig_Environment($loader);
echo $twig->render('Hello {{ name }}!', array('name' => 'mano'));

Updated by Martin Rademacher 4 months ago

Also, this works too and might be a step to using sf2 templating...

use Symfony\Component\Templating\PhpEngine;
use Symfony\Component\Templating\TemplateNameParser;
use Symfony\Component\Templating\Loader\FilesystemLoader;

$tnp = new TemplateNameParser();
$l = new FilesystemLoader();
$pe = new PhpEngine($tnp, $l);
echo $pe->render(dirname(__FILE__).'/foo.php');

Updated by Martin Rademacher 4 months ago

Consider refactoring part of the current view code into a sf2 compatible template engine and change View to pick the engine that can handle a give template

Updated by Martin Rademacher 4 months ago

  • Target version changed from 1.0 to 0.9.15

Updated by Martin Rademacher 4 months ago

  • Target version changed from 0.9.15 to 0.9.14

Updated by Martin Rademacher 4 months ago

Progressing nicely, with only one (rather ugly) issue left:

Store emails send from admin can't use twig templates - well, at least not within a store context.

Updated by Martin Rademacher 3 months ago

  • Status changed from In Progress to Resolved

I would consider this done for now - you can use twig, although with limitations. If those limits are an issue we should have separate tracker to handle those.

  1. Twig templating is not available for emails in admin
  2. No integration/tools/macros or anything else beside providing the same template vars that we have in ZenMagick PHP templates

Also available in: Atom PDF