Item1697: RENDERHEAD can't be treated like a regular macro
Priority: Normal
Current State: No Action Required
Released In:
Target Release: minor
Applies To: Engine
Component:
Branches:
RENDERHEAD writes out all stuff that has been registered using ADDTOHEAD. If RENDERHEAD now gets processed before all ADDTOHEADs have been visited, results will only be partial. In addition, its output will be redundant as
writeCompletePage()
has got its own mechanisms to add the same information once again.
I will remove RENDERHEAD and implement it properly in
writeCompletePage()
while adding it to the html header only when no
RENDERHEAD was found.
While looking at that stuff I've found out that _SORTEDHEADERS weren't finalized as _HTMLHEADERS where thus resulting in all sorts of problems in a persistent perl setting.
Hi Michael,
Could you please fix
AddToHeadTests.pl
in the unit tests, I desperately need to work out a very bizarre
addToHead()
problem (briefly mentioned in
Item1950). I'd like to add my test case into
AddToHeadTests.pl
once it's working again.
I had a quick go at trying to use
_genHeaders()
but it's giving me an empty string
Thanks
--
PaulHarvey - 21 Aug 2009
Hm
_genHeaders()
should be fine.
The RENDERHEAD is now expanded within
Foswiki::writeCompletePage()
as part of the final step in creating the html body. I don't know how to test the things in
AddToHeadTest.pm
other than calling
_genHeaders()
. Actually this is the first time I see this test as it is missing from the MANIFEST so that
pseudo-install.pl
never installed it.
--
MichaelDaum - 21 Aug 2009
It may be that
genHeaders()
does work, I just don't know how to use it. I thought that perhaps I needed to set up a Foswiki session? It wasn't obvious to me in the 5 minutes I gave it...
--
PaulHarvey - 26 Aug 2009
There should be a call to
Foswiki::_genHeaders()
in the tests. That's what
RENDERHEAD
does in
Foswiki::writeCompletePage()
and then inserts the return value into the page. Have you tried something along these lines:
--- test/unit/AddToHeadTests.pm (revision 4704)
+++ test/unit/AddToHeadTests.pm (working copy)
@@ -25,10 +25,10 @@
my $topicName = $this->{test_topic};
my $webName = $this->{test_web};
- my $raw_tag = '%ADDTOHEAD{text="QQQ"}%%RENDERHEAD%';
+ my $raw_tag = '%ADDTOHEAD{text="QQQ"}%';
my $expected = "<!-- --> QQQ";
- my $result =
- Foswiki::Func::expandCommonVariables( $raw_tag, $topicName, $webName );
+ Foswiki::Func::expandCommonVariables( $raw_tag, $topicName, $webName );
+ my $result = Foswiki::_genHeaders();
$this->assert_equals( $expected, $result );
}
--
MichaelDaum - 26 Aug 2009
That's exactly what I did, but it didn't work (empty string). Did it work for you? I am new to
UnitTestContrib, perhaps there's something dumb I've done wrong..
--
PaulHarvey - 26 Aug 2009
Need to check whether these unit tests are running.
--
PaulHarvey - 16 Jan 2010
Is this still relevant, since we switched to zones?
--
CrawfordCurrie - 25 Jun 2010
No action required anymore. The zone concept deliberately was designed to overcomes these kind of problems. Expansion of RENDERZONE is delayed until the very end of the rendering loop while still participating in the normal left-to-right-inside-out parsing process, so that it now can be treated like a normal macro.
--
MichaelDaum - 25 Jun 2010