Skip to content

Commit

Permalink
added support for application/ld+json (#353)
Browse files Browse the repository at this point in the history
  • Loading branch information
simPod authored and dg committed Nov 20, 2023
1 parent af6fc60 commit cd22b5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Latte/Compiler/Escaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function enterHtmlText(ElementNode $el): void
if ($el->is('script')) {
$type = $el->getAttribute('type');
if ($type === true || $type === null
|| is_string($type) && preg_match('#((application|text)/(((x-)?java|ecma|j|live)script|json)|text/plain|module|importmap|)$#Ai', $type)
|| is_string($type) && preg_match('#((application|text)/(((x-)?java|ecma|j|live)script|json)|application/.+\+json|text/plain|module|importmap|)$#Ai', $type)
) {
$this->subType = self::JavaScript;

Expand Down
5 changes: 5 additions & 0 deletions tests/common/contentType.html.javascript.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ Assert::match(
$latte->renderToString('<script type="application/json">{ foo:{="<>"} }</script>'),
);

Assert::match(
'<script type="application/ld+json">{ foo:"<>" }</script>',
$latte->renderToString('<script type="application/ld+json">{ foo:{="<>"} }</script>'),
);

Assert::match(
'<script type="importmap">{ foo:"<>" }</script>',
$latte->renderToString('<script type="importmap">{ foo:{="<>"} }</script>'),
Expand Down

0 comments on commit cd22b5b

Please sign in to comment.