On Wed, Sep 23, 2015 at 9:27 AM, Bryn Jeffries
<bryn.jeffr...@sydney.edu.au> wrote:
> I  wrote:
>>> I have several scripts (Groovy and Velocity) that generate output that 
>>> should not be rendered as a Wiki page. This is necessary, for example, when 
>>> rendering JSON. As documented before 
>>> (http://extensions.xwiki.org/xwiki/bin/view/Extension/Output+JSON) , it's 
>>> possible to allow such content by including request parameters xpage=plain 
>>> and outputSyntax=plain. However, this approach requires all pages that 
>>> refer to the script to remember to include these parameters, which is 
>>> rather error prone.
>>>
>>> Is there a way for a script to explicitly disable rendering instead?
>
> Vincent replied:
>> Yes, there is :)
>>
>> For Groovy, see 
>> http://extensions.xwiki.org/xwiki/bin/view/Extension/Script+Macro
>> (check the output and wiki parameters)
>>
>> For Velocity, see 
>> http://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity+Macro
>> (same parameter names).
>
> OK, so trying both options with a content body
>
> {{velocity output="false" wiki="false"}}
> $response.setContentType('application/json')
> {
> "greeting" : "Hello",
> "location": "World"
> }
> {{/velocity}}
>
> I get a document of Content-Script-Type  text/javascript but with a 38KB file 
> of HTML containing the usual Wiki page content, which I'd like to avoid. I 
> think if I explicitly set xpage=plain in the request then the template skips 
> rendering this stuff, but what I was wondering was whether I could set this 
> from within my script instead.

There is two different things, wiki="false" indicate that the source
is plain text but by default the output is html so to make sure to
have only your page content and rendered as plain text you can use add
/get/ action and outputSyntax=plain in the URL as in:

http://platform.xwiki.org/xwiki/bin/get/Main/SecondGenerationWiki?outputSyntax=plain

See 
http://platform.xwiki.org/xwiki/bin/view/DevGuide/Standard+URL+Format#HAction:get
and 
http://platform.xwiki.org/xwiki/bin/view/DevGuide/Standard+URL+Format#HParameter:outputSyntaxandoutputSyntaxVersion
for more details.

> _______________________________________________
> users mailing list
> users@xwiki.org
> http://lists.xwiki.org/mailman/listinfo/users



-- 
Thomas Mortagne
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to