Feature Proposal: Make zones less intrusive, especially for non-HTML output
Motivation
- It's impossible to emit custom HTML without contamination from unwanted plugin output. So simply let the skin authors use
%RENDERZONE{"head"}%
and %RENDERZONE{"script"}%
explicitly
- Foswiki.pm isn't the place for zones code. If anything, it might go in Render.pm
- The
if $contentType ne 'text/plain'
is just a bit mad, we can do better than that
- Wasting CPU cycles on requests that don't do anything with zones, let alone output HTML
Description and Documentation
Two main changes, the first removes the assumption that we
always want zones rendered with output which happens to contain a "</head>" string:
diff --git a/core/lib/Foswiki.pm b/core/lib/Foswiki.pm
index 562a64c..478b738 100644
--- a/core/lib/Foswiki.pm
+++ b/core/lib/Foswiki.pm
@@ -755,11 +755,6 @@ JS
$cgis, $context, $usingStrikeOne )/gei;
}
- if ( $contentType ne 'text/plain' ) {
-
- $text = $this->_renderZones($text);
- }
-
# SMELL: can't compute; faking content-type for backwards compatibility;
# any other information might become bogus later anyway
my $hdr = "Content-type: " . $contentType . "\r\n";
diff --git a/core/templates/foswiki.tmpl b/core/templates/foswiki.tmpl
index 5a4674b..fbd6a29 100644
--- a/core/templates/foswiki.tmpl
+++ b/core/templates/foswiki.tmpl
@@ -74,8 +74,10 @@ Item2476: Put IE8 into compatibility mode to work around slow, erratic textarea
<link rel="alternate" href="%SCRIPTURL{edit}%/%BASEWEB%/%BASETOPIC%?t=%GMTIME{"$epoch"}%" type="application/x-wiki" title="edit %BASETOPIC%" />
<meta name="description" content="%TOPIC%" />
<base href="%SCRIPTURL{%SCRIPTNAME%}%/%WEB%/%TOPIC%" /><!--[if IE]></base><![endif]-->
- %TMPL:P{"script"}%
%TMPL:P{"defaultstyle"}%
+ %RENDERZONE{"head"}%
+ %RENDERZONE{"script"}%
+ %TMPL:P{"script"}%
</head>%TMPL:END%%{
---------------------------------------------------
}%%TMPL:DEF{"titleaction"}%%TMPL:END%%{
Secondly, refactor the code out of Foswiki.pm.
Examples
Impact
Implementation
--
Contributors: PaulHarvey - 12 Nov 2010
Discussion
I guess we could make a Foswiki.spec to preserve compatibility with 1.1 skins which rely on the existing
s/</head>/STUFF/
behaviour.
OTOH any skin that inherits
foswiki.tmpl
version of
head
DEF should be fine
--
PaulHarvey - 12 Nov 2010
The patch is absolutely the right thing to do next now that skins and plugins have been infiltrated by zones to a sufficient level.
I agree that we should add an
{AutoRenderStandardZones}
kind of setting to the foswiki specs, which defaults to off.
Sol old skins can be made working switching it on again.
--
MichaelDaum - 17 Nov 2010
Looks like this should be accepted. Since it looks simple enough, slotting it into 2.1, But let's discuss.
--
Main.GeorgeClark - 27 Jul 2015 - 01:21