node-ssi
node-ssi copied to clipboard
Feature request: Continue SSI processing if failure to resolve an include occurs with ssi.compile and ssi.compileFile
Example: An HTML file has the following three includes:
<!--#include virtual="/includes/header.html" -->
<!--#include virtual="/includes/content.html" -->
<!--#include virtual="/includes/footer.html" -->
In my situation, the first and last include do not exist on my local development environment, however they will be available once pushed to the test / prod. environment. I am only concerned about rendering the second include, content.html.
The problem is that since the first include does not exist, ssi.compileFile (and ssi.compile) throws an error which means the downstream includes are not processed. In my case, I am using ssi.compile().
return ssi.compile(text, function (err, content) {
});
As a workaround, I was thinking I could grab the failed reference from err
, and parse the original input file content to remove the offending reference then pass this back in to ssi.compile / ssi.compileFile until it has fully processed.
Would like to get your thoughts on implementing continuation of processing on error, however.
I've created a Gist that demonstrates my workaround, which works to continue SSI processing if an ssi.compile() fails due to an invalid reference. See https://gist.github.com/cookch10/b85e3ca0a372fa7b7dff