Skip to content

Instantly share code, notes, and snippets.

@herveguetin
Created October 25, 2018 17:48
Show Gist options
  • Save herveguetin/11ba88901e20ccd3c730f2515907a724 to your computer and use it in GitHub Desktop.
Save herveguetin/11ba88901e20ccd3c730f2515907a724 to your computer and use it in GitHub Desktop.
Directive interpolation in Magento 2
class SomeClass
{
public function __construct(
\Magento\Framework\Filter\Template $templateFilter
)
{
$this->templateFilter = $templateFilter;
}
public function getDirectiveContent()
{
return $this->templateFilter
->setVariables(['who' => 'World'])
->filter('Hello {{var who}}');
// Hello World
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment