Defining Velocity Templates

Comments

9 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) 
    1
    Comment actions Permalink
  • 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

    0
    Comment actions Permalink
  • 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

    0
    Comment actions Permalink
  • 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

    0
    Comment actions Permalink
  • 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?

     

    0
    Comment actions Permalink
  • 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)

    1
    Comment actions Permalink
  • 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

    0
    Comment actions Permalink
  • Avatar
    Marieve

    Please, 

    How does it works with monospaced? 

    0
    Comment actions Permalink
  • Avatar
    K15t Team

    Hi Marieve,

    If you wanted to render text that was formatted as "monospace" in Confluence with a custom style, you would need to add an new entry for this element in your atlassian-plugin.xml:

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

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

    #if($renderStart)
        <span class="my-custom-style" style="font-family: monospace;">
    #else
        </span>
    #end

    In this example, monospace is defined for the font-family but of course you could specify a specific font name.

    Following this change, exporting text that has been formatted as monospace should now be rendered with this custom class when exported with that theme.

    I hope this helps.

    Thanks, Thomas (K15t)

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk