On Feb 23, 2009, at 9:22 AM, Marius Dumitru Florea wrote:
> Hi Jerome,
>
> Jerome Velociter wrote:
>> Marius Dumitru Florea wrote:
>>> Hi Vincent,
>>>
>>> Vincent Massol wrote:
>>>> Hi,
>>>>
>>>> Here's what a user was expecting to work (see
>>>> http://jira.xwiki.org/jira/browse/XWIKI-3258)
>>>> :
>>>>
>>>> {{html}}
>>>> <table>
>>>> {{velocity}}
>>>> #set ($serverDocuments = [$xwiki.getDocument("Main.WebHome"),
>>>> $xwiki.getDocument("Sandbox.WebHome")])
>>>> #set ($serverClass = "XWiki.MyClass")
>>>> #foreach ($serverDocument in $serverDocuments)
>>>> <tr>
>>>> <td>$serverDocument.space</td>
>>>> <td>$serverDocument.name</td>
>>>> <td>
>>>> #foreach($serverObject in
>>>> $serverDocument.getObjects($serverClass))
>>>> * whatever
>>>> #end
>>>> </td>
>>>> <td>[[$serverDocument]]</td>
>>>> </tr>
>>>> #end
>>>> {{/velocity}}
>>>> </table>
>>>> {{/html}}
>>>>
>>>> This is not correct since the HTML macro must contain valid HTML
>>>> and
>>>> this is clearly not the case (the content is parsed by an XML
>>>> parser
>>>> and element content are then parsed using the wiki syntax parser).
>>>>
>>>> So I'm +1 to close this issue as won't fix.
>>>>
>>>> I see lots of users making the mistake but I don't see a solution
>>>> right now.
>>>>
>>>> WDYT?
>>> I haven't understood why the HTML is invalid and why velocity macro
>>> should be put first.
>> I think because
>>
>> "
>> {{velocity}}
>>
>> #set ($serverDocuments = [$xwiki.getDocument("Main.WebHome"),
>> [...]
>>
>> "
>> Is not valid as <table> content.
>
> I'm surprised. Without knowing too much about how macros are
> executed, I
> fill it's natural that if we support nested macros then the inner
> macros
> should be executed first so that the outer macros can use the output
> for
> their own purpose.
Here's how it works:
* There's no notion of nested macros. Each macro does whatever it
wants with its content. Some examples:
- The HTML macro considers it has HTML content and does 3 things:
- call the HTML cleaner on its content to make it valid XHTML
and thus valid XML
- use an XML parser to parse the content
- for each XML element, call the wiki syntax parser on it (if
wiki=true which is the default)
- The velocity macro calls velocity on its content
- The code macro doesn't call any wiki parser on its content even
if it contains {{...}} symbols
* The macro execution order is about top level macros present in the
page and finding which ones to execute first. This works recursively
so that macros can generate other macros (such as the {{include}}
macro for ex - it has the a high priority so that it's executed first).
* Thus as you can see it's the top level macro that controls what it
does and is executed *first*.
Hope it's more clear and hope it's intuitive enough once you
understand it.
Thanks
-Vincent
> Are you telling me that the html macro ignores inner
> macros but velocity doesn't?
>
> Thanks,
> Marius
>
>>
>> As long as we can write that kind of script the other way round (with
>> {{velocity}} before {{html}}), I'm ok to close as won't fix.
>>
>> Jerome
>>
>>> Thanks,
>>> Marius
>>>
>>>> Thanks
>>>> -Vincent
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs