External Pretty Code

Last modified by Vincent Massol on 2026/06/02 17:54

cogGets code located at an external URL and pretty prints it
TypeSnippet
Category
Developed by

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Description

Using XWiki Syntax 2.0

{{velocity}}
{{code language="java"}}
$xwiki.getURLContent("https://fisheye2.atlassian.com/browse/~raw,r=10166/xwiki/xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/Api.java")
{{/code}}
{{/velocity}}

Using XWiki Syntax 1.0

Information

The Radeox Code Macro escapes everything that's put inside it. This is why we need to use some trick as shown below.

## Use a variable to bypass the code macro escaping running before velocity.
## The upper case is here to make sure it's bypassed even if another code macro
## follows our block
#set($codevar = "{CODE}")
$codevar.toLowerCase()
$xwiki.getURLContent("http://fisheye2.cenqua.com/browse/~raw,r=trunk/xwiki/xwiki-platform/core/trunk/xwiki-core/src/main/java/com/xpn/xwiki/api/Api.java")
$codevar.toLowerCase()

Get Connected