<div dir="ltr"><div>Hi all,</div><div> More of a Template Toolkit question rather than Dancer per se, but is there a better way to load a file only if it exists?</div><div><br></div><div>From my Googling around, it appears the only approaches are (a) Try/Catch in TT or (b) include a full <%PERL%> call (which I'm guessing may be a little heavy to do on every page load).</div><div><br></div><div>I'd like to dynamically include a help file if it exists, otherwise provide a 'No help available for this page' message. Current code looks like this:</div><div><font face="monospace, monospace"><% help_file = 'help' _ request.request_uri.remove('\?.*') _ '.tt' %></font></div><div><font face="monospace, monospace"><% TRY %></font></div><div><font face="monospace, monospace">   <% USE File('/full_unix_path/views/' _ help_file) %></font></div><div><font face="monospace, monospace">   <% INCLUDE $help_file %></font></div><div><font face="monospace, monospace"><% CATCH File %></font></div><div><font face="monospace, monospace">   '<% help_file %>' doesn't exist: <% <a href="http://error.info">error.info</a> %></font></div><div><font face="monospace, monospace"><% END %></font></div><div><br></div><div>I'm not keen on the fixed path and it seems overkill to have to try/catch if the file exists rather than just load it (and fail silently) or test if it exists and then load.</div><div><br></div><div>Do people have better patterns for managing inline help?</div><div><br></div><div>thanks,</div><div>Nathan</div></div>