jigsaw icon indicating copy to clipboard operation
jigsaw copied to clipboard

Check for a valid blade extension when handling blade files

Open jwpage opened this issue 3 years ago • 0 comments

Blade files without valid exceptions in will cause an exception to be thrown during building. This is particularly noticeable with editor swap files (eg. vim has .foo.blade.php.swp) preventing the site from building. (Also reported in #274)

❯ ./vendor/bin/jigsaw build

Building local site
Building files from source...


In Factory.php line 291:

  Unrecognized extension in file: /Volumes/Code/home/jigsaw-test/source/foo.blade.bar.


build [--pretty PRETTY] [-c|--cache [CACHE]] [--] [<env>]

This PR makes BladeHandler::shouldHandle check that the file has a valid extra blade extension (as defined in extraBladeExtensions, or a standard blade.php extension. If not, it will be rendered by the default handler.

I'm not sure if this is the best approach, as it would silently let unlisted blade extensions pass through without the user being aware of it, but seems better than breaking the build entirely.

Would it possibly be better if we display a warning to the user notifying them of an invalid blade extension instead?

jwpage avatar Sep 23 '21 23:09 jwpage