Webiny\Component\TemplateEngine\Bridge\Smarty\Smarty::assign PHP Method

assign() public method

Assign a variable and its value into the template engine.
public assign ( string $var, mixed $value ) : void
$var string Variable name.
$value mixed Variable value.
return void
    public function assign($var, $value)
    {
        $this->smarty->assign($var, $value);
    }

Usage Example

Example #1
0
 /**
  * @dataProvider dataProvider
  */
 public function testRegisterExtensions(Smarty $smarty)
 {
     DemoComponent::setConfig(__DIR__ . '/Mocks/DemoComponentConfig.yaml');
     $smarty->registerExtensions();
     $smarty->assign('name', 'WORLD');
     $result = $smarty->fetch('DemoComponent.tpl');
     $this->assertSame('Hello world', $result);
 }