Quantcast
Channel: phpBB.com
Viewing all articles
Browse latest Browse all 2318

phpBB Custom Coding • Re: [SOLVED] Does anyone understand Twig macros?

$
0
0
Just thought: for extra diapers in emergencies it really should have ignore_missing thrown into the mix, just in case some muppet loses their en-gb file.

This is where the Twig docs lead to fun and games. They don't give you the required syntax for adding it to an include function that has a list of templates to check for. They give the syntax for when you are only checking for one file...

Code:

{{ include('sidebar.html.twig', ignore_missing: true) }}
...but they do not give you the syntax for when you are checking against a list of files. This, by implication, might lead you to try several variations on the syntax they gave as an example. White pages of death ensue. Giggles all round.

As it turns out (and I found this by trial and error) the correct syntax is this:

Code:

{{ include(['language/' ~ S_USER_LANG ~ '/styleStrings.twig', 'language/en-gb/styleStrings.twig'], ignore_missing=true) }}
That will simply skip the include if you are somehow clever enough to lose all your styleStrings files. No white pages of death. Just missing text. Much less indigestion for muppets. :D

Statistics: Posted by Gumboots — Sat Apr 12, 2025 8:45 pm



Viewing all articles
Browse latest Browse all 2318

Trending Articles