Skip to content

Commit

Permalink
bug #153 Skipping null values from rendering (sadikoff)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the main branch.

Discussion
----------

Skipping null values from rendering

Hi there!

This should fix a weird situation when we are rendering stringified `null` value attribute and stimulus using `null` string as a value instead of just skipping it.

Commits
-------

20bc66d Skipping null values from rendering
  • Loading branch information
weaverryan committed Nov 29, 2021
2 parents 5dde155 + 20bc66d commit 028fc75
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Twig/StimulusTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ public function renderStimulusController(Environment $env, $dataOrControllerName
$controllers[] = $controllerName;

foreach ($controllerValues as $key => $value) {
if (null === $value) {
continue;
}

if (!is_scalar($value)) {
$value = json_encode($value);
}
Expand Down

0 comments on commit 028fc75

Please sign in to comment.