gantry / gantry5

:rocket: Next Generation Template / Theme Framework
http://gantry.org
1.03k stars 203 forks source link

Particles in their own subdir show a non-descriptive error on Layout save with Grav #3191

Open fcFn opened 1 year ago

fcFn commented 1 year ago

Description

If you try to put particles into their own subfolder e.g. particles/my-particle on Grav, Gantry will crash at preg_match() with Unknown modifier: m on layout save.

Steps to reproduce:

  1. Follow the steps in the docs for Grav.
  2. Create a subdirectory, e.g. /particles/my-particle, and put your particle files there.
  3. Use the particle in the Layout editor and save the layout.

Expected behavior:

It should either save the layout without throwing an exception or display a better error message that would indicate what should be fixed such as "Please make sure your particle files are inside the root of the particle directory".

Possible fixes:

N8Solutions commented 1 year ago

Just my 2-cents here @fcFn. The documentation doesn't discuss the ability to place a particle into it's own subfolder under the TEMPLATE_DIR/custom/particles folder so the expected behavior is that this would fail, not that it would work.

So you're proposed "fix" isn't actually a fix, but rather it is considered to be an enhancement. If the files for the particles were all under one folder, i.e. .scss .yaml .twig & .js (if needed) then I could understand this but since those files are all under separate folders, I don't find your proposed enhancement necessary.

Can you provide a good case for the reasoning behind wanting to do this? I'm honestly curious because under the /particles folder there are only 2 files per particle, the .twig and the .yaml files.

fcFn commented 1 year ago

@N8Solutions You're right. Perhaps it should just fail with a better message instead of what it does now, such as "Please make sure your particle files are inside the root of the particles directory" (this is on Grav by the way, I'll edit the post). Or maybe it should be mentioned that particles has to be a flat directory in the docs.