Search code examples
velocityxwiki

Render HTML inside velocity includeInContext() XWiki


I have two spaces. One is the "view" page and the other is the "tool" page. I want to render the "tool" on various "view" pages through my wiki, within the context of the view. Currently, in the "view" page I use:

{{velocity}}
#includeInContext("Interfaces.tool.WebHome")
{{/velocity}}

This works fine and I can retrieve for example the children or data of the "view" page with the code in the "tool" page, which is what I want.

However, if I include an:

{{velocity}}

 {{html wiki="true"}}
   <tag ... html></tag>
 {{/html}}

{{/velocity}}

In the "tool" page, the html is only rendered as text in the "view" page. I've also tried moving the {{html}} tags to the "view" page or wiki="false" but with no luck. Any other ideas to try? Maybe some other function than includeInContext()?


Solution

  • #includeInContext is partially deprecated. You should use the new {{include}} wiki macro, which in your case would look like:

    {{include reference="Interfaces.tool.WebHome"/}}
    

    You don't need the {{velocity}} wrappers in the view page either, just the {{include}} macro.