Defining Velocity Templates

Comments

7 comments

  • Avatar
    Thomas Rough (K15t)
    Hi Volker, 
     
    Thanks for reaching out to us. 
     
    It’s currently not possible to add a custom vm file for user macros. But if you only want to apply some CSS style to the output of your user macro you can do the following:
     
    1. Add the “scroll-unprocessed” class to the outer div in your user macro. This will cause the exporter to directly insert the HTML of the user macro without applying any changes.
     
    Example:
     
    ## @noparams
    <div class="scroll-unprocessed my-macro">
       <p>User macro</p>
       $body
    </div>
     
     
    2. You should now be able to add CSS for your custom CSS classes in your template:
     
    Example:
     
    .my-macro, .my-macro p {
        border: 1px solid black;
    }
     
    I hope this information helps. 
     
    Cheers, Thomas (k15t Software) 
  • Avatar
    K15t Team

    Hi Volker,

    there is a predefined list of elements that can be overwritten with a custom VM file. This is a list of all the names that can be used there: attachmentlink, blockerror, blockquote, citation, color, documentlink, heading, image, info, inlineerror, inlineimage, italics, itemizedlist, tasklist, linebreak, link, linktarget, listitem, tasklistitem, monospaced, note, orderedlist, page, panel, para, paragraph, pi, programlisting, section, status, strikethrough, strong, subscript, superscript, table, tablebody, tablecell, tablefooter, tableheader, tablerow, text, tip, underline, warning, footnote, bookmark, horizontalrule

    For example if you wanted to render text that was formatted as "strikethrough" in Confluence with a custom style, you would add a new entry for this element in your atlassian-plugin.xml:

    <resource type="template-part" name="strikethrough" location="my/theme/path/strikethrough.vm"/>

    And then add a custom Velocity file at the location set above:

    #if($renderStart)
    <span class="my-custom-style" style="text-decoration: line-through;">
    #else
    </span>
    #end

     

    Exporting text that has been formatted as strikethrough should now be rendered with this custom class when exported with that theme.

    Cheers, Thomas (K15t)

  • Avatar
    Volker Weinreich

    Hi Thomas,

    yes, thank you, this information helps regarding the css styles for a user macro.

    But could you please explain the part Defining Velocity Templates (optional) in your guide https://help.k15t.com/scroll-html-exporter/creating-a-template-75367699.html

    Okay, I can change the existing vm files.

    But what does that mean?: "For each Velocity template that should be overwritten, define a resource element with type template-part in the atlassian-plugin.xml file."

    I think they are already defined in the atlassian-plugin-xml. What else resource element I could define? 

    So, in what case I can add custom vm file? Or is it that I could use the existing resource referrals or not?

    Greetings,

    Volker

  • Avatar
    Volker Weinreich

    Hi Thomas,

    no, the approach with class="scroll-unprocessed doesn't seem to work. Okay, I can change the css. But now eyery link within the  body of the user macro doesn't work in the exported html. And images within the body aren't shown either.

    What to do?

    Greetings,

    Volker

  • Avatar
    Volker Weinreich

    Hi Thomas,

    after further tests with different html-elements, I have discovered, that I can use <table> and <td> to apply classes within my user macro. These classes are not deleted while exporting the content. So I am independent from scroll-unprosessed. So links and images are working.

    Greetings,

    Volker

  • Avatar
    Volker Weinreich

    Okay, nevertheless this an open question for me: What for I can define a resource element in the atlassian-plugin.xml

    "For each Velocity template that should be overwritten, define a resource element with type template-part in the atlassian-plugin.xml file."

    Okay, I can change the supplied VM-files themselves, but why should I change the resource-lines in the atlassian-plugin.xml? Can you give me an example please?

     

  • Avatar
    Volker Weinreich

    Okay, thank you, Thomas. This is the list of elements, which I needed. And thanks for the example. I would suggest, that you add this information to the help page: https://help.k15t.com/scroll-html-exporter/creating-a-template-75367699.html

    Greetings,

    Volker

Please sign in to leave a comment.

Powered by Zendesk