Skip to content

Commit e045bd6

Browse files
committed
Filter import with option prototype
1 parent 412ffc6 commit e045bd6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Phug/Compiler/ImportCompiler.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Phug\CompilerException;
77
use Phug\Formatter\ElementInterface;
88
use Phug\Parser\Node\ImportNode;
9+
use Phug\Parser\Node\TextNode;
910
use Phug\Parser\NodeInterface;
1011

1112
class ImportCompiler extends AbstractNodeCompiler
@@ -69,8 +70,17 @@ public function compileNode(NodeInterface $node, ElementInterface $parent = null
6970
}
7071

7172
$compiler = $this->getCompiler();
72-
$subCompiler = clone $compiler;
7373
$path = $this->resolvePath($node->getPath());
74+
75+
if ($filter = $node->getFilter()) {
76+
$node->appendChild(new TextNode(file_get_contents($path)));
77+
$element = $compiler->compileNode($node, $parent);
78+
$node->remove();
79+
80+
return $element;
81+
}
82+
83+
$subCompiler = clone $compiler;
7484
$element = $subCompiler->compileFileIntoElement($path);
7585

7686
if ($node->getName() === 'include') {

0 commit comments

Comments
 (0)