Skip to content

Commit

Permalink
Tweaked script/style tag formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mahagr committed Oct 31, 2017
1 parent 84789cb commit 7c19d15
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Twig/Node/TwigNodeScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function compile(\Twig_Compiler $compiler)
$compiler
->write("ob_start();\n")
->subcompile($this->getNode('body'))
->write("\$content = ob_end_clean();")
->write("\$content = ob_get_clean();")
->write("\$assets->addInlineJs(\$content, \$priority, \$group, \$attributes);\n");
}
}
Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/Twig/Node/TwigNodeStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function compile(\Twig_Compiler $compiler)
$compiler
->write("ob_start();\n")
->subcompile($this->getNode('body'))
->write("\$content = ob_end_clean();")
->write("\$content = ob_get_clean();")
->write("\$assets->addInlineCss(\$content, \$priority, \$group);\n");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
/**
* Adds a script to head/bottom/custom location in the document.
*
* {% script 'theme://js/something.js' in 'bottom' priority 20 with { defer: true, async: true } %}
* {% script 'theme://js/something.js' in 'bottom' priority: 20 with { defer: true, async: true } %}
*
* {% script in 'bottom' priority 20 %}
* {% script in 'bottom' priority: 20 %}
* alert('Warning!');
* {% endscript %}
Expand Down Expand Up @@ -71,6 +71,7 @@ protected function parseArguments(\Twig_Token $token)

$priority = null;
if ($stream->nextIf(\Twig_Token::NAME_TYPE, 'priority')) {
$stream->expect(\Twig_Token::PUNCTUATION_TYPE, ':');
$priority = $this->parser->getExpressionParser()->parseExpression();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
/**
* Adds a style to the document.
*
* {% style 'theme://css/foo.css' priority 20 %}
* {% style 'theme://css/foo.css' priority: 20 %}
* {% style priority 20 with { media: 'screen' } %}
* {% style priority: 20 with { media: 'screen' } %}
* a { color: red; }
* {% endstyle %}
*/
Expand Down Expand Up @@ -64,6 +64,7 @@ protected function parseArguments(\Twig_Token $token)

$priority = null;
if ($stream->nextIf(\Twig_Token::NAME_TYPE, 'priority')) {
$stream->expect(\Twig_Token::PUNCTUATION_TYPE, ':');
$priority = $this->parser->getExpressionParser()->parseExpression();
}

Expand Down

0 comments on commit 7c19d15

Please sign in to comment.