This adds a simple new shortcode that can be used to run assertions in templates. This can be useful to test data integrity at template level and provide more helpful error messages. For example, using an author on d.c.c that has no proper data in the i18n files, fails with
[11ty] 2. (./site/_includes/layouts/home.njk) [Line 23, Column 27]
[11ty] EleventyShortcodeError: Error with Nunjucks shortcode `Img` (via Template render error)
[11ty] 3. ERROR IN ./site/en/index.md, IMG image/tcFciHGuF3MxnTr1y5ue01OGLBn2/PFaMfvDZoPorronbpdU8.svg: alt text must be a string, received a object (via Template render error)
[11ty]
By using this shortcode like this:
{% Assert value=authorTitle | i18n(locale) | dump != '{}', error='No i18n data for author ' + authorId %}
This adds a simple new shortcode that can be used to run assertions in templates. This can be useful to test data integrity at template level and provide more helpful error messages. For example, using an author on d.c.c that has no proper data in the i18n files, fails with
By using this shortcode like this:
The user knows what's wrong without consulting infra. Part of https://github.com/GoogleChrome/developer.chrome.com/issues/4327.