Skip to content

Commit

Permalink
Fix twig lexer
Browse files Browse the repository at this point in the history
Reintroduced lexer switch, fixing issue with id selectors being interpreted as twig comments.
  • Loading branch information
fryiee committed Dec 1, 2020
1 parent a5b038e commit ab6cfab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/en/01.prologue/02.change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ Features that are deprecated will generally be removed in the next `minor` updat

## Releases

### [1.8.16] - 2020-12-01
### Fixed
- Reintroduced lexer switch, fixing issue with id selectors being interpreted as twig comments.

### [1.8.15] - 2020-11-24
### Fixed
- Fixed issue with theme config targeting non-existent default theme.
Expand Down
14 changes: 14 additions & 0 deletions src/Asset/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,14 @@ protected function publish($path, $collection, $additionalFilters)
* Parse the content. Always parse CSS.
*/
if (in_array('parse', $filters) || $hint == 'css') {
$twig = resolve('twig');

$twig->setLexer(
new \Twig_Lexer($twig, [
'tag_comment' => ['{^', '^}']
])
);

try {
$contents = (string) render($contents);
} catch (\Exception $e) {
Expand All @@ -575,6 +583,12 @@ protected function publish($path, $collection, $additionalFilters)

\Log::error($e->getMessage());
}

$twig->setLexer(
new \Twig_Lexer($twig, [
'tag_comment' => ['{#', '#}']
])
);
}

if (in_array('min', $filters) && $hint == 'css') {
Expand Down

0 comments on commit ab6cfab

Please sign in to comment.