Permalink
Browse files

new symfony task to generate the extensions

  • Loading branch information...
1 parent 547616d commit dece875e88526fcef6b3555bbb0b235d69b08448 Videla Alvaro committed Oct 12, 2009
Showing with 22 additions and 0 deletions.
  1. +22 −0 lib/task/sfTwigHelperToExtensionTask.class.php
@@ -0,0 +1,22 @@
+<?php
+
+class sfTwigHelperToExtensionTask extends sfPluginBaseTask
+{
+ protected function configure()
+ {
+ $this->namespace = 'twig';
+ $this->name = 'helpers';
+
+ $this->briefDescription = 'Convert symfony helpers to Twig Extensions';
+ }
+
+ protected function execute($arguments = array(), $options = array())
+ {
+ $pluginDir = sfApplicationConfiguration::getActive()->getPluginConfiguration('sfTwigPlugin')->getRootDir();
+ $helperDir = sfApplicationConfiguration::getActive()->getSymfonyLibDir() . '/helper/';
+
+ $command = sprintf('cd %s; ./helpers.sh %s', $pluginDir, $helperDir);
+ exec($command, $output);
+ echo implode(PHP_EOL, $output), "\n";
+ }
+}

4 comments on commit dece875

@fabpot
fabpot commented on dece875 Oct 12, 2009

Why not create only one extension for all symfony helpers? I think it would make more sense and be faster.

@henrikbjorn

Yes that was what, i was thinking a extension per helper and a extension to load other extension into the current twig environment (so we have the same functionality as use_helper). And i am not that fund of the way it just assumes it all should be filters, need to make a decistion which should be filters and which should not. include_partial should be a Twig tag maybe named "partial "module/name" to mimic as much native behavior from the original sfPHPView

@videlalvaro
Owner

I think we can take this is script as a base for future improvements. I will take a more detailed look into Tags

@henrikbjorn

i have started a HelperHelper_Twig_Extension with a use tag for including extensions directly from templates, please send the changes back to the main branch thanks :)

Please sign in to comment.