flosch/pongo2 — pull request #67 by fromYukki (2014-12-02 11:30:47+00:00)
Title: Tags: `if_exists` flag for include tag

Hello

Let me introduce the `if_exists` flag for `include` tag.
The main idea of this flag was the need to include files that can not exist with out error (like normal behaviour).

For example your application is running on a huge website and your website has different layouts or part of layouts for each venture.

For example you have VN, SG, MY ventures. And each venture has its own folder with templates `templates/VENTURE_CODE/` but all file names are the same. And you need to include to the meta tag Alexa code for VN venture.

Ok, the best way to create new file `templates/VN/partial/alexa_code.html` and then just include it to the main layout file like this `{% include "partial/alexa_code.html" %}`. Everything is fine except for one: somebody forgot to create `alexa_code.html` for and MY and SG ventures. And everything is broken ;)

Now you will have a solution! ;)
Just put `{% include "partial/alexa_code.html" if_exists %}` and you save your ass out of troubles!

Regards
Maksim