Skip to content

Commit

Permalink
Expose sharedVariables via options
Browse files Browse the repository at this point in the history
  • Loading branch information
kylekatarnls committed Dec 12, 2017
1 parent c945872 commit 3f5125c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Jade/Engine/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ class Options extends Keywords
*/
public function getOption($name)
{
switch ($name) {
case 'sharedVariables':
case 'shared_variables':
case 'globals':
return isset($this->sharedVariables) ? $this->sharedVariables : null;
}

if (!array_key_exists($name, $this->options)) {
throw new \InvalidArgumentException("$name is not a valid option name.", 2);
}
Expand Down
6 changes: 6 additions & 0 deletions tests/features/share.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public function testShare()

$html = $jade->render("p\n =foo\n =' '\n =bar\n | !");
$this->assertSame('<p>Hello world!</p>', $html);

$this->assertSame(array(
'answear' => 42,
'foo' => 'Hello',
'bar' => 'world',
), $jade->getOption('globals'));
}

public function testResetSharedVariables()
Expand Down

0 comments on commit 3f5125c

Please sign in to comment.