Open alexander-schranz opened 1 year ago
Another note: an exception does not allow to implement the fallback feature if the only API you have is ->render()
, as you don't want the fallback to apply if the template exists but include another template for which we have a failure (with no fallback there). Twig used to be able to use an exception-based logic for that thanks to its loadTemplate
API that only loads (and compiles) a template without rendering it (and so without resolving other imports which might trigger the exception as well). Without that, you don't know whether the exception is for your own template or a referenced one.
@stof that is great insight knowledge about the handling. Thank you for sharing!
There are currently 2 options we can use. There can be a TemplateNotFoundException or a exist method on the
TemplateRendererInterface
. As feedback from@fabpot
here: https://github.com/php-fig/fig-standards/pull/1280#issuecomment-1143306242:So the exception isn't ideal and a
exist
method is better. We need to check which