Skip to content

Commit

Permalink
Merge pull request #39 from s4msung/master
Browse files Browse the repository at this point in the history
pass options to parser for include and extend
  • Loading branch information
kylekatarnls authored Jul 25, 2016
2 parents 694d034 + 0e789c4 commit 5727d74
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Jade/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ protected function parseExtends()
$path = $this->getTemplatePath($this->expect('extends')->value);

$string = $this->getTemplateContents($path);
$parser = new static($string, $path);
$parser = new static($string, $path, $this->options);
// need to be a reference, or be seted after the parse loop
$parser->blocks = &$this->blocks;
$parser->contexts = $this->contexts;
Expand Down Expand Up @@ -437,7 +437,7 @@ protected function parseInclude()

$string = $this->getTemplateContents($path);

$parser = new static($string, $path);
$parser = new static($string, $path, $this->options);
$parser->blocks = $this->blocks;
$parser->mixins = $this->mixins;

Expand Down
33 changes: 33 additions & 0 deletions tests/features/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,39 @@ public function testBaseDir()
"<div class=\"alert alert-danger\">Page not found.</div>\n" .
"<div class=\"alert alert-danger\">Page not found.</div>";
$this->assertSame($expected, $actual);

$actual = $this->renderWithBaseDir(
__DIR__ . '/../templates/',
__DIR__ . '/../templates/auxiliary/include-basedir.jade'
);
$expected = "<p>World</p>\n" .
"<div class=\"alert alert-danger\">Page not found.</div>\n" .
"<p>World</p>\n" .
"<p>World</p>\n" .
"<div class=\"alert alert-danger\">Page not found.</div>\n" .
"<p>World</p>";
$this->assertSame($expected, $actual);

$actual = $this->renderWithBaseDir(
__DIR__ . '/../templates/',
__DIR__ . '/../templates/auxiliary/extends-basedir.jade'
);
$expected =
"<html>\n" .
"<head>\n" .
"<title>My Application</title>\n" .
"</head>\n" .
"<body>\n" .
"<h1>test</h1>\n" .
"<p>World</p>\n" .
"<div class=\"alert alert-danger\">Page not found.</div>\n" .
"<p>World</p>\n" .
"<p>World</p>\n" .
"<div class=\"alert alert-danger\">Page not found.</div>\n" .
"<p>World</p>\n" .
"</body>\n" .
"</html>";
$this->assertSame($expected, $actual);
}

public function testClassAttribute()
Expand Down
4 changes: 4 additions & 0 deletions tests/templates/auxiliary/extends-basedir.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
extends /auxiliary/extends-include-sibling

block content
h1 test
6 changes: 6 additions & 0 deletions tests/templates/auxiliary/extends-include-sibling.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
html
head
title My Application
body
block content
include /auxiliary/include-sibling
1 change: 1 addition & 0 deletions tests/templates/auxiliary/include-basedir.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include /auxiliary/include-sibling

0 comments on commit 5727d74

Please sign in to comment.