Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Revert "Example implementation of the «sf» tag."

This reverts commit 5c84d4f.
  • Loading branch information...
commit 87928987eb79575b8ed19dd08373c48932c470cc 1 parent b6600cf
@henrikbjorn authored
View
28 _simple.php
@@ -1,28 +0,0 @@
-<?php
-
-require_once dirname(__FILE__).'/lib/vendor/Twig/lib/Twig/Autoloader.php';
-Twig_Autoloader::register();
-require dirname(__FILE__).'/lib/extension/sfTwigExtensionAsset.class.php';
-require dirname(__FILE__).'/lib/tokenparser/sfTwigTokenParserAsset.class.php';
-require dirname(__FILE__).'/lib/node/sfTwigNodeAsset.class.php';
-
-$loader = new Twig_Loader_Array(array(
- 'index' => <<<EOF
-
-{% sf include_component(foo, bar, ['a': 'b']) %}
-
-EOF
- ,
-));
-
-$twig = new Twig_Environment($loader, array('debug' => false, 'cache' => false));
-$twig->addExtension(new sfTwigExtensionAsset());
-
-//echo $twig->tokenize($twig->getLoader()->getSource('index'), 'index');
-//echo $twig->parse($twig->tokenize($twig->getLoader()->getSource('index'), 'index'))."\n\n";
-echo $twig->compile($twig->parse($twig->tokenize($twig->getLoader()->getSource('index'), 'index')))."\n\n";
-
-
-$template = $twig->loadTemplate('index');
-echo $template->render(array());
-echo "\n\n";
View
65 lib/node/sfTwigNodeAsset.class.php
@@ -1,65 +0,0 @@
-<?php
-
-class sfTwigNodeAsset extends Twig_Node/* implements Twig_NodeListInterface*/
-{
- protected $helper;
- protected $values;
- protected $isMultitarget;
-
- public function __construct($helper, $values, $lineno, $tag = null)
- {
- parent::__construct($lineno, $tag);
-
- $this->helper = $helper;
- $this->values = $values;
- }
-/*
- public function __toString()
- {
- $repr = array(get_class($this).'('.($this->isMultitarget ? implode(', ', $this->names) : $this->names).',');
- foreach ($this->isMultitarget ? $this->values : array($this->values) as $node)
- {
- foreach (explode("\n", $node->__toString()) as $line)
- {
- $repr[] = ' '.$line;
- }
- }
- $repr[] = ')';
-
- return implode("\n", $repr);
- }
-
- public function getNodes()
- {
- if ($this->isMultitarget)
- {
- return $this->values;
- }
- else
- {
- return array($this->values);
- }
- }
-
- public function setNodes(array $nodes)
- {
- $this->values = $this->isMultitarget ? $nodes : $nodes[0];
- }
-*/
- public function compile($compiler)
- {
- $compiler->addDebugInfo($this);
-
- $compiler->write($this->helper."(");
- foreach ($this->values as $idx => $value)
- {
- if ($idx)
- {
- $compiler->raw(', ');
- }
-
- $compiler->subcompile($value);
- }
- $compiler->write(");\n");
- }
-}
View
25 lib/tokenparser/sfTwigTokenParserAsset.class.php
@@ -1,25 +0,0 @@
-<?php
-
-class sfTwigTokenParserAsset extends Twig_TokenParser
-{
- public function parse(Twig_Token $token)
- {
- $lineno = $token->getLine();
- $token = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE);
- $helper = $token->getValue();
- $this->parser->getStream()->expect(Twig_Token::OPERATOR_TYPE, '(');
-
- list(, $values) = $this->parser->getExpressionParser()->parseMultitargetExpression();
-
- $this->parser->getStream()->expect(Twig_Token::OPERATOR_TYPE, ')');
- $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
-
- return new sfTwigNodeAsset($helper, $values, $lineno, $this->getTag());
- }
-
- public function getTag()
- {
- return 'sf';
- }
-}
-

0 comments on commit 8792898

Please sign in to comment.
Something went wrong with that request. Please try again.