mirror of
https://github.com/processwire/processwire.git
synced 2025-08-15 03:05:26 +02:00
Fix issue processwire/processwire-issues#302 where markup <region>
tags didn't get removed if template file produced no output
This commit is contained in:
@@ -1315,6 +1315,7 @@ class WireMarkupRegions extends Wire {
|
|||||||
if(!count($regions)) {
|
if(!count($regions)) {
|
||||||
if($debug) $htmlDocument = str_replace($debugLandmark, "<pre>No regions</pre>$debugLandmark", $htmlDocument);
|
if($debug) $htmlDocument = str_replace($debugLandmark, "<pre>No regions</pre>$debugLandmark", $htmlDocument);
|
||||||
$recursionLevel--;
|
$recursionLevel--;
|
||||||
|
if(!$recursionLevel) $this->removeRegionTags($htmlDocument);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1480,7 +1481,7 @@ class WireMarkupRegions extends Wire {
|
|||||||
* @return bool True if tags or attributes were removed, false if not
|
* @return bool True if tags or attributes were removed, false if not
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function removeRegionTags(&$html) {
|
public function removeRegionTags(&$html) {
|
||||||
|
|
||||||
$updated = false;
|
$updated = false;
|
||||||
|
|
||||||
|
@@ -544,6 +544,9 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
|||||||
*/
|
*/
|
||||||
protected function populateMarkupRegions(&$html) {
|
protected function populateMarkupRegions(&$html) {
|
||||||
|
|
||||||
|
$markupRegions = new WireMarkupRegions();
|
||||||
|
$this->wire($markupRegions);
|
||||||
|
|
||||||
$pos = stripos($html, '<!DOCTYPE html');
|
$pos = stripos($html, '<!DOCTYPE html');
|
||||||
|
|
||||||
if($pos === false) {
|
if($pos === false) {
|
||||||
@@ -552,14 +555,15 @@ class PageRender extends WireData implements Module, ConfigurableModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if no document start, or document starts at pos==0, then nothing to populate
|
// if no document start, or document starts at pos==0, then nothing to populate
|
||||||
if(!$pos) return;
|
if(!$pos) {
|
||||||
|
// there still may be region related stuff that needs to be removed like <region> tags
|
||||||
|
$markupRegions->removeRegionTags($html);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// split document at doctype/html boundary
|
// split document at doctype/html boundary
|
||||||
$htmlBefore = substr($html, 0, $pos);
|
$htmlBefore = substr($html, 0, $pos);
|
||||||
$html = substr($html, $pos);
|
$html = substr($html, $pos);
|
||||||
$markupRegions = new WireMarkupRegions();
|
|
||||||
$this->wire($markupRegions);
|
|
||||||
|
|
||||||
$options = array('useClassActions' => true);
|
$options = array('useClassActions' => true);
|
||||||
$config = $this->wire('config');
|
$config = $this->wire('config');
|
||||||
$version = (int) $config->useMarkupRegions;
|
$version = (int) $config->useMarkupRegions;
|
||||||
|
Reference in New Issue
Block a user