On Wed, Sep 23, 2015 at 9:27 AM, Bryn Jeffries
<bryn.jeffries(a)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:
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:
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users