Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Assets.php #1687

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions system/src/Grav/Common/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -663,14 +663,18 @@ public function js($group = 'head', $attributes = [])

// Render Inline JS
foreach ($this->inline_js as $inline) {
if ($group && $inline['group'] == $group) {
if ($group && $inline['group'] === $group && $inline['type'] === '') {
// concatenate inlined js if type is empty
$inline_js .= $inline['asset'] . "\n";
} else {
// build a script tag if inline type is set
$attributeString = " type=\"" . $inline['type'] . "\"";
$output .= "\n<script" . $attributeString . ">\n" . $inline['asset'] . "\n</script>\n";
}
}

if ($inline_js) {
$attribute_string = isset($inline) && $inline['type'] ? " type=\"" . $inline['type'] . "\"" : '';
$output .= "\n<script" . $attribute_string . ">\n" . $inline_js . "\n</script>\n";
$output .= "\n<script>\n" . $inline_js . "\n</script>\n";
}

return $output;
Expand Down