preaction / Statocles

Static website CMS
http://preaction.me/statocles
Other
84 stars 33 forks source link

All included content is run through the template renderer, even if it shouldn't be #529

Open preaction opened 7 years ago

preaction commented 7 years ago

Right now, all uses of the include helper function have their included file run through the template processor. This makes a huge problem if the file we're including looks similar enough to a template (has a % in the first column, for example, like most any Perl code would).

So if I have a file called script.pl that looks like:

my (
    %files,
);

And I then try to include that file using include:

%= include 'script.pl'

I will get an error about the "bareword files not allowed here" since it's being run through the template generator.

We should make this as intuitive as possible for the common case, while also allowing people to override the intuitive behavior to force the behavior they want. To achieve this, we should make it so only some types of files are rendered automatically, like .ep, .markdown, and .md. We should also add some flags to the include helper that allow disabling the rendering (-raw) or forcing the rendering (-render).

This is a breaking change, so we'll have to be vocal about it. If we can find a way to smooth this change over, that would be ideal, but I'm not coming up with a good idea right now.

preaction commented 7 years ago

I've added the -raw flag in Statocles 0.083 so that people can override the default behavior. It may be that we just leave it like this to satisfy back-compat, but I'm not sure I like that idea...