On Thu, Jan 10, 2013 at 3:06 PM, David Cornforth
<[email protected]> wrote:
> Thanks for the reply.
>
> I already have some code written in Groovy that creates the required tables 
> in xwiki syntax, and I am attempting to convert it into a deployable Macro.  
> This is why I am trying to return text such as "|=one|=two" in the xwiki 
> syntax.  As you say, I could convert all the code to use TableBlock etc, but 
> this seems like a lot more work than just using the existing code as-is and 
> returning the current xwiki syntax output.
>
> When I create the RawBlock I am explicitly setting the syntax to be xwiki 
> rather than xhtml: new RawBlock("|=one|=two",Syntax.XWIKI_2_0)  I would then 
> have expected this to be rendered into a table header once the Macro had 
> returned the output.  Is this not how a RawBlock should be used?  If not, 
> what is the purpose of setting the syntax on the RawBlock?  Perhaps I'm 
> misunderstanding how this area works?

The purpose of indicating the syntax is just that, indicating the
syntax so that the renderer knows what it's dealing with but it's not
xhtml renderer job to call the xwiki/2.0 parser. If you want your
macro to behave like the groovy macro then do the same thing: generate
some wiki content in a string and then use the parser you need to
generate the XDOM for you.

>
> Is it possible to output text in xwiki syntax (e.g. "|=one|=two") from the 
> execute method of the Macro and have the output rendered into a table?
>
>
> 10 January 2013 12:40 Thomas Mortagne [[email protected]]:
>> Looks like you are mixing several things here.
>>
>> RawBlock job is to provide something that should ends up in the output 
>> syntax as it is but the xhtml renderer can't support something that is in 
>> xwiki syntax so it skips it which is why you don't get anything.
>>
>> When you say that you want a WordBlock("|=one|=two") by definition this is 
>> not going to be interpreted since you already
>> said this was a word so whatever the renderer it will get a event saying 
>> that you want to print something that exactly
>> looks like "|=one|=two" and the renderer should make sure it will looks like 
>> this (the html renderer will escape < and >
>> when you have some for example etc.)
>>
>> If you want your macro to return a table you should explicitly return a 
>> table which mean use
>> TableBlock/TableRowBlock/TableCellBlock/TableHeadCellBlock.
>
>> On Wed, Jan 9, 2013 at 1:52 PM, David Cornforth <[email protected]> 
>> wrote:
>>> I am following the guide for creating a Macro by extending AbstractMacro: 
>>> http://rendering.xwiki.org/xwiki/bin/view/Main/ExtendingMacro although I 
>>> have implemented it in Groovy rather than core Java.
>>>
>>> I have managed to get the example to successfully build with maven and for 
>>> the resulting JAR file to work with my xwiki Enterprise 4.4 install.
>>>
>>> I then changed the content of the execute method to:
>>>
>>>     List<Block> result = Arrays.<Block> asList(new WordBlock("|=one|=two"))
>>>     return result
>>>
>>> And added a new .test file:
>>>
>>>     .runTransformations
>>>     .#-----------------------------------------------------
>>>     .input|xwiki/2.1
>>>     .# Test the macro in standalone mode
>>>     .#-----------------------------------------------------
>>>     {{releases artifactIds="test1,test2" server="test3"/}}
>>>     .#-----------------------------------------------------
>>>     .expect|xhtml/1.0
>>>     .#-----------------------------------------------------
>>>     |=one|=two
>>>
>>> This test passed when running the maven build, but produced the text output 
>>> "|=one|=two" when deployed to xwiki, rather than rendering a table.  I then 
>>> changed the execute method to:
>>>
>>>     List<Block> result = Arrays.<Block> asList(new 
>>> RawBlock("|=one|=two",Syntax.XWIKI_2_0))
>>>     return result
>>>
>>> with the same test as above.  This time the test does not pass, and fails 
>>> with the error:
>>>
>>>     releases1.test [xwiki/2.1,
>>> xhtml/1.0](org.xwiki.rendering.test.integration.RenderingTest):
>>> expected:<[|=one|=two]> but was:<[]>
>>>
>>> When deployed to xwiki there is no output either.  As such, I can't seem to 
>>> get RawBlock to actually output my pre-formatted xwiki code.
>>>
>>> Am I doing something wrong with my use of RawBlock?
>>> How can I get xwiki syntax content (e.g. a table) to output from the 
>>> execute method so that a) the tests pass and b) the content is rendered 
>>> into a table?
>>>
>>> ______________________________________________________________________
>>> __ This e-mail has been scanned for all known viruses by Star
>>> Internet. The service is powered by MessageLabs.
>>> ______________________________________________________________________
>>> __ _______________________________________________
>>> users mailing list
>>> [email protected]
>>> http://lists.xwiki.org/mailman/listinfo/users
>>
>>
>>
>>--
>>Thomas Mortagne
>>_______________________________________________
>>users mailing list
>>[email protected]
>>http://lists.xwiki.org/mailman/listinfo/users
>>
>>________________________________________________________________________
>>This e-mail has been scanned for all viruses by Star. The service is powered 
>>by MessageLabs. For more information on a proactive anti-virus service 
>>working around the clock, around the globe, visit:
>>http://www.star.net.uk
>>________________________________________________________________________
>
> ________________________________________________________________________
> This e-mail has been scanned for all known viruses by Star Internet. The
> service is powered by MessageLabs. 
> ________________________________________________________________________
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users



--
Thomas Mortagne
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to