title: In freemarker is it possible to check to see if a file exists before including it?
body: <p>We are trying to build a system in freemarker where extension files can be optionally added to replace blocks of the standard template.  </p>
  
  <p>We have gotten to this point </p>
  
  <pre><code>&lt;#attempt&gt;
      &lt;#include "extension.ftl"&gt;
  &lt;#recover&gt;
      Standard output
  &lt;/#attempt&gt;
  </code></pre>
  
  <p>So - if the extension.ftl file exists it will be used otherwise the part inside of the recover block is output.</p>
  
  <p>The problem with this is that freemarker always logs the error that caused the recover block to trigger.  </p>
  
  <p>So we need one of two things:</p>
  
  <ol>
  <li>Don't call the include if the file doesn't exist - thus the need to check for file existence.</li>
  </ol>
  
  <p>-OR-</p>
  
  <ol start="2">
  <li>A way to prevent the logging of the error inside the recover block without changing the logging to prevent ALL freemarker errors from showing up.</li>
  </ol>