Defining Velocity Templates
Hi,
in Confluence I have created some user macros for formatting. They are enclosed by divs with a class name. Now the HTML-Exporter of course doesn't know these user macros. So I can't modify the stylesheets for them in the exported html.
It seems, that I just have to add a line in the atlassian-plugin-xml in our own template like
<resource type="template-part" name="[USER MACRO NAME]" location="com/k15t/scroll/scroll-webhelp-theme/scroll-html/admonition.vm"/>
But that doesn't work. I also tried it with the class name. I also tried to give the div in the user macro the additional class name "confluence-information-macro".
It only works, when I include a macro like "note" oder "info" into the user macro the HTML-Exporter recognises it and processes it using the admonition-vm. But I want to be independent from the confluence-information-macros.
How can I address the user macro in the atlassian-plugin-xml and use one of the given vm files or create own vm-files? Do I have to create classes for user macros? How can I integrate them in the HTML Exporter?
Greetings,
Volker
-
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)
-
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
-
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
-
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?
-
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>
#endExporting text that has been formatted as strikethrough should now be rendered with this custom class when exported with that theme.
Cheers, Thomas (K15t)
-
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
-
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>
#endIn 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)
Please sign in to leave a comment.
Comments
9 comments