On Feb 3, 2010, at 12:47 PM, Jerome Velociter wrote:
On 2/3/10 12:24 PM, Thomas Mortagne wrote:
On Wed, Feb 3, 2010 at 12:12, Jerome
Velociter<jerome(a)xwiki.com> wrote:
+0
What will be the "new way" of checking syntax in velocity ?
#if($doc.syntax.type == "xwiki"&& $doc.syntax.version ==
"2.0")
...
#end
No the goal is to stop testing for "2.0".
When you want to test one specific syntax you can still use
#if($doc.syntaxId == "xwiki/1.0")
#end
that doe snot change.
Well it will be deprecated no ? So you are not encouraged to use this.
doc.syntaxId will be deprecated but not doc.syntax.toIdString()
-Vincent
But in some cases we ant to do
#if($doc.syntax.type == "xwiki"&& $doc.syntax.version !=
"1.0")
#end
to cover all xwiki syntax that are not the old very different xwiki/1.0 syntax.
I see.
Jerome.
>
>>
>> ?
>>
>> Jerome
>>
>>
>> On 2/3/10 12:00 PM, Vincent Massol wrote:
>>> Hi,
>>>
>>> I'd like to make this change for 2.2RC1 (since I don't see any danger
about it, although that's subjective and if we don't agree I could wait for
2.3M1).
>>>
>>> <explanation>
>>> The story behind this is because we need to get access to the Syntax object
from templates in a few places order to check the syntax used. Right now for example we do
the following in macros.vm for the livetable macro:
>>>
>>> #if($doc.syntaxId == "xwiki/2.0")
>>>
>>> The pb is that this is going to fail in the future when we introduce the
XWiki 2.1 syntax (which we're preparing with Thomas).
>>>
>>> To fix this we'll need to check that syntax.getType ==
"xwiki"&& syntax.getVersion> 1.0 instead.
>>>
>>> I also wanted to convert some panels to 2.0 syntax for 2.2 final but that
requires to convert macros.vm's #panelheader to work fine with all syntaxes rather
than adding ugly checks in panel code itself... (or wrapping them all with unnecessary
html macros).
>>> </explanation>
>>>
>>> Here's my +1 for doing it now (although I'm also +1 for doing it but
in 2.3M1).
>>>
>>> Note that doing now has one advantage: In order to implement it cleanly we
need to break an API, namely: CoreConfiguration.getDefaultDocumentSyntax would return
Syntax instead of returning String now. Since this API isn't used from Velocity and is
pretty new there's little risk to break lots of people but better modify it ASAP than
wait.
>>>
>>> Thanks
>>> -Vincent