This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from yannickl88/master
Made inline webpack tag
- Loading branch information
Showing
7 changed files
with
173 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
namespace Hostnet\Bundle\WebpackBundle\Twig\Node; | ||
|
||
/** | ||
* @author Yannick de Lange <[email protected]> | ||
*/ | ||
class WebpackInlineNode extends \Twig_Node | ||
{ | ||
/** | ||
* @param array $attributes An array of attributes (should not be nodes) | ||
* @param int $lineno The line number | ||
* @param string $tag The tag name associated with the Node | ||
*/ | ||
public function __construct(array $attributes = array(), $lineno = 0, $tag = null) | ||
{ | ||
parent::__construct([], $attributes, $lineno, $tag); | ||
} | ||
|
||
/** {@inheritdoc} */ | ||
public function compile(\Twig_Compiler $compiler) | ||
{ | ||
if (false !== ($file = $this->getAttribute('js_file'))) { | ||
$compiler | ||
->write('echo ') | ||
->string('<script type="text/javascript" src="'. $file .'"></script>') | ||
->raw(";\n"); | ||
} | ||
if (false !== ($file = $this->getAttribute('css_file'))) { | ||
$compiler | ||
->write('echo ') | ||
->string('<link rel="stylesheet" href="'. $file .'">') | ||
->raw(";\n"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters