On Feb 3, 2010, at 12:12 PM, Jerome Velociter wrote:
+0
What will be the "new way" of checking syntax in velocity ?
#if($doc.syntax.type == "xwiki"&& $doc.syntax.version ==
"2.0")
No, that would the same as before.
I think the best would be to create a Version class with a format. For example:
get/setMinor(), get/setMajor() which use integers.
So you'd write:
#if($doc.syntax.type == "xwiki" && $doc.syntax.version.major > 1)
Obviously you'd use this only in backward-compatibility scenarios since the best
solution is not to have to use it, i.e. to create a WikiMacro or a Java Macro proper (for
the livetable example).
Note: This Version class would be useful also for the product version and for extension
versions when we implement the extension manager.
-Vincent
...
#end
?
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