From ac779c79a898e4b26e05f176491490255937214a Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Mon, 26 Feb 2018 09:58:29 -0500 Subject: [PATCH] Fix issue processwire/processwire-issues#302 where markup `` tags didn't get removed if template file produced no output --- wire/core/WireMarkupRegions.php | 3 ++- wire/modules/PageRender.module | 12 ++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/wire/core/WireMarkupRegions.php b/wire/core/WireMarkupRegions.php index 62ae1991..dc114a96 100644 --- a/wire/core/WireMarkupRegions.php +++ b/wire/core/WireMarkupRegions.php @@ -1315,6 +1315,7 @@ class WireMarkupRegions extends Wire { if(!count($regions)) { if($debug) $htmlDocument = str_replace($debugLandmark, "
No regions
$debugLandmark", $htmlDocument); $recursionLevel--; + if(!$recursionLevel) $this->removeRegionTags($htmlDocument); return 0; } @@ -1480,7 +1481,7 @@ class WireMarkupRegions extends Wire { * @return bool True if tags or attributes were removed, false if not * */ - protected function removeRegionTags(&$html) { + public function removeRegionTags(&$html) { $updated = false; diff --git a/wire/modules/PageRender.module b/wire/modules/PageRender.module index 7c482998..9368386b 100644 --- a/wire/modules/PageRender.module +++ b/wire/modules/PageRender.module @@ -543,6 +543,9 @@ class PageRender extends WireData implements Module, ConfigurableModule { * */ protected function populateMarkupRegions(&$html) { + + $markupRegions = new WireMarkupRegions(); + $this->wire($markupRegions); $pos = stripos($html, ' tags + $markupRegions->removeRegionTags($html); + return; + } // split document at doctype/html boundary $htmlBefore = substr($html, 0, $pos); $html = substr($html, $pos); - $markupRegions = new WireMarkupRegions(); - $this->wire($markupRegions); - $options = array('useClassActions' => true); $config = $this->wire('config'); $version = (int) $config->useMarkupRegions;