I'm having trouble getting the correct data passed in my twig extension
Example token parser parse
function:
public function parse(\Twig_Token $token)
{
$parser = $this->parser;
$stream = $parser->getStream();
$firstVariable = $stream->getCurrent();
}
The expression {% myTag "someString" %}
will set $firstVariable
as 'someString'.
However if we put in place a variable:
{% set someVariable = "someString" %}
{% myTag someVariable %}
You end up with a name type with the value 'someVariable' instead of the expected variable value 'someString'
How do I properly parse the first argument of my custom twig tag, allowing the input to either be a string or a variable containing a string?
Edit
It looks like you can just take the variable name and use it in the returned twig node.
public function compile(){
$compiler->write('echo "$context[$variableName]"');
}
But I need access to it before compiling.
Edit I no longer believe it's possible to access the context before compiling. Making this question a dud unless anyone has some more information to share on the subject