processwire / processwire-requests

ProcessWire feature requests.
40 stars 0 forks source link

Delete unused/empty Markup Regions in "_main" layout file #91

Open ethnoxcom opened 7 years ago

ethnoxcom commented 7 years ago

Short description of the enhancement

This improvement is related to the new <region> or <pw-region> tags, it will automatically eliminate the empty region tags from the final markup.

Optional: Steps that explain the enhancement

  1. in the _main.php file I declared an empty <pw-region> in the head section to allow add new styles from templates files
  2. if in the template file I don't need to put content in that region, simply I don't do anything
  3. during page rendering the empty <pw-region> are deleted from final markup

Current vs. suggested behavior

Currently when I don't need to put content from the template file in a empty region declared in the layout file, I need to explicitly write the empty region again eg: <pw-region id="head-styles"></pw-region> to be removed and so on for each (empty) region declared and unused, otherwise is printed in the final output. If a region during the final rendering is empty of content, must be automatically removed from the markup.

Why would the enhancement be useful to users?

Avoids the repetition of tasks in every template file that if not taken into account can generate the output of illegal tags in sections of the html document

ryancramerdesign commented 7 years ago

@PixraelR I'm not sure I understand. I put a <pw-region id='foobar'></pw-region> in my _main.php file, and nothing in any other files. The pw-region tag does not remain in the final output markup. It sounds like you are saying that it does? Or have I misunderstood? Thanks.

ethnoxcom commented 7 years ago

You are right, the day I publish this request I did several tests and it worked as I describe, but now I removed the empty regions declarations in my templates files and it works correctly. Thank you, I already closed this topic.

ethnoxcom commented 7 years ago

I found out how this happens, if I don't do any markup output in the template file to leave the original output from _main, then PW does not delete the region tags in _main output markup