mirror of
https://github.com/getgrav/grav.git
synced 2026-03-04 19:41:36 +01:00
Tweaked script/style tag formatting
This commit is contained in:
@@ -94,7 +94,7 @@ class TwigNodeScript extends \Twig_Node implements \Twig_NodeOutputInterface
|
||||
$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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class TwigNodeStyle extends \Twig_Node implements \Twig_NodeOutputInterface
|
||||
$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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ use Grav\Common\Twig\Node\TwigNodeScript;
|
||||
/**
|
||||
* 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 %}
|
||||
|
||||
@@ -71,6 +71,7 @@ class TwigTokenParserScript extends \Twig_TokenParser
|
||||
|
||||
$priority = null;
|
||||
if ($stream->nextIf(\Twig_Token::NAME_TYPE, 'priority')) {
|
||||
$stream->expect(\Twig_Token::PUNCTUATION_TYPE, ':');
|
||||
$priority = $this->parser->getExpressionParser()->parseExpression();
|
||||
}
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ use Grav\Common\Twig\Node\TwigNodeStyle;
|
||||
/**
|
||||
* 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 %}
|
||||
*/
|
||||
@@ -64,6 +64,7 @@ class TwigTokenParserStyle extends \Twig_TokenParser
|
||||
|
||||
$priority = null;
|
||||
if ($stream->nextIf(\Twig_Token::NAME_TYPE, 'priority')) {
|
||||
$stream->expect(\Twig_Token::PUNCTUATION_TYPE, ':');
|
||||
$priority = $this->parser->getExpressionParser()->parseExpression();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user