- Issue created by @goz
- Merge request !152Issue #3506389: Follow default_value defined in JSON schema into twig → (Open) created by goz
- 🇫🇷France just_like_good_vibes PARIS
nice job, just a simple reserve with the usage of
is not defined
we need to check that this usage is ok.
- 🇫🇷France pdureau Paris
Check usage of " is not defined" when Twig is used with
strict_variables = false
(which is the default value in both Twig and Drupal, and expected setting in a component templating point of view):If set to
false
, Twig will silently ignore invalid
variables (variables and or attributes/methods that do not exist) and
replace them with anull
value. When set totrue
, Twig throws an
exception instead (default tofalse
).And how it fit or not with
default()
filter.According to the results, we may need to update
sdc_devel
rules and documentation - 🇫🇷France pdureau Paris
I am still not very confortable, but I have to admit... it looks OK ;)
So, what do we do in sdc_devel side ? Do we allow
defined
tests by removing it from "Not needed in Drupal because strict_variables=false." warning ?Only for boolean (may be hard to detect) ?
Or maybe we adopt a more liberal approach of Twig tests where we only forbid the one we know to be very harmful:
-
constant
: related to Drupal installtion -
empty
: same as just testing the variable -
null
: same as just testing the variable -
same as
: too strict for templating, confusing if used with Jinja
https://git.drupalcode.org/project/sdc_devel/-/blob/1.0.x/src/Plugin/Twi...
-
- 🇫🇷France just_like_good_vibes PARIS
hello,
discussed today, we wait for the feedback - 🇫🇷France pdureau Paris
Related SDC DEVEL issue : 📌 Adopt a more liberal approach for TwigValidatorRuleTestExpr Active
Let's wait what will happen there.