Use hash tables
With the absence of labels in radio-items of data definitions, I wondered if I could use a hash table in Velocity to translate radio-item values into CSS class names?
For example, if the XML is
<category>Security Update</category>
Using key -> value notation, the hash table would be
'Security Update' -> 'update-top-border'
What would the velocity be to output the HTML?
<div class="callout update-top-border"
data-equalizer-watch>
Discussions are closed to public comments.
If you need help with Cascade CMS please
start a new discussion.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by Wing Ming Chan on 02 Aug, 2016 09:47 PM
Hi,
Assuming that you can retrieve the data, say, using the Locator tool, you can create a hashmap in a format, to be included and consumed by another format. See https://github.com/wingmingchan/velocity/blob/master/tutorials/01%2... for an example on how to use methods like
putAll
andget
. Also see http://www.upstate.edu/cascade-admin/formats/velocity/api-documenta... and https://docs.oracle.com/javase/8/docs/api/java/util/LinkedHashMap.html for the API documentation.Wing
2 Posted by Ryan Griffith on 03 Aug, 2016 12:34 PM
Hi,
If you're dealing with a small subset and don't mind maintaining the values in an additional place, you can go simple and define your map as such:
You would then use that map:
Please let me know if you have any questions.
Thanks!
3 Posted by c-siems on 03 Aug, 2016 01:21 PM
Wing, thanks for the resources. Your Velocity tutorials are easy enough for me to understand.
Thanks Ryan, I think that's what I need.
4 Posted by Ryan Griffith on 03 Aug, 2016 01:28 PM
Not a problem at all!
I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.
Have a great day!
Ryan Griffith closed this discussion on 03 Aug, 2016 01:28 PM.