Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-13005

Add scripting API to render a document as a full HTML page



    • Easy


      We can render a document using $doc.getRenderedContent() but if that document generates skin extension hooks (e.g. by including 'stylesheets.vm' or by calling #skinExtensionHooks Velocity macro) they will not be replaced with resource includes (e.g. style sheets includes). For this we need to call PluginManager#endParsing() (because the hooks are replaced by the SSX plugin for instance) but this is protected API that cannot be called from Velocity unless you have PR.

      We should add:

       * Produces the input for the editor by rendering the specified content template as a full HTML page, making sure
       * the skin extension hooks are resolved. The template is rendered in the context of the current document and the
       * Velocity context is not isolated so you can put the data needed by the template in the Velocity context before
       * calling this method. The advantage of using this method to obtain the editor input is that the editor doesn't
       * have to make an additional HTTP request for the content template.
       * @param templateReference specifies the document that serves as the template for the editor content
       * @return the result of rendering the specified content template
       * @since 7.4.1, 8.0M1
      String render(DocumentReference templateReference);

      usable like this:

      <textarea class="wysiwyg">$escapetool.xml($services.wysiwyg.render('Some.Content.Template'))</textarea>

      This is useful for any WYSIWYG editor.


        Issue Links



              mflorea Marius Dumitru Florea
              mflorea Marius Dumitru Florea
              0 Vote for this issue
              3 Start watching this issue