Redaxscript\Assetic\Transport::render PHP Method

render() public method

render the javascript variables
Since: 3.0.0
public render ( string $key = null, mixed $value = null ) : string
$key string
$value mixed
return string
    public function render($key = null, $value = null)
    {
        $output = null;
        if (is_array($value)) {
            foreach ($value as $keyChildren => $valueChildren) {
                $output .= 'window.' . $key . '.' . $keyChildren . ' = ' . json_encode($valueChildren) . ';';
            }
        } else {
            $output = 'window.' . $key . ' = ' . json_encode($value) . ';';
        }
        return $output;
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * testRender
  *
  * @since 3.0.0
  *
  * @param array $transportArray
  * @param string $expect
  *
  * @dataProvider providerRender
  */
 public function testRender($transportArray = [], $expect = null)
 {
     /* setup */
     $transport = new Assetic\Transport($this->_registry, $this->_language);
     /* actual */
     $actual = $transport->render($transportArray['key'], $transportArray['value']);
     /* compare */
     $this->assertEquals($expect, $actual);
 }
All Usage Examples Of Redaxscript\Assetic\Transport::render