Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Confused about Roll Templates

I'm trying to get some roll templates to work, and having problems. I'm sure it's something dumb, but I can't figure it out. I have this template: <rolltemplate class="sheet-rolltemplate-survival"> <div><strong>Result:</strong> {{result}}</div> <div>{{notes}}</div> </rolltemplate> and I'm calling it in a macro with &{template:survival} {{ result=Dead }} {{ notes=Eaten by a groo }} and I get this result Result:  Dead The second parameter doesn't come through. If I switch to template:default,  both fields come through.  What's weird is that it sometimes works, but I can't replicate it. Other times, neither field comes through. I'm using a custom character sheet and setting the html that way. Any help would be appreciated.
1606195576

Edited 1606195664
vÍnce
Pro
Sheet Author
See if this works by adding roll template  logic  tags; <rolltemplate class="sheet-rolltemplate-survival"> {{#result}} <div><strong>Result:</strong> {{result}}</div> {{/result}} {{#notes}} <div>{{notes}}</div> {{/notes}} </rolltemplate>
That didn't help. Looking at the output message source with the Chrome inspection tool, the note divs are not there, which seems consistent with the idea that there is just no notes value being passed.
1606228876
Andreas J.
Forum Champion
Sheet Author
Translator
I suggest you take a look at other basic, functioning roll templates, such as Jacob's Better Rolltemplate: <a href="https://wiki.roll20.net/Roll_Templates#Jakob.27s_Better_Default_Rolltemplate" rel="nofollow">https://wiki.roll20.net/Roll_Templates#Jakob.27s_Better_Default_Rolltemplate</a> It's also possible you're missing some critical CSS for the template. Don't know if it matters, but usually I see rolltemplate macros written without those extra spaces you have, don't know if that makes any difference: &amp;{template:survival} {{result=Dead}} {{notes=Eaten by a groo}}
1606229029

Edited 1606229080
Kraynic
Pro
Sheet Author
What happens if you remove the space between the leading curly brackets and your section identifier?&nbsp; Instead of {{ notes, try {{notes.&nbsp; Just throwing the template in (I used Vince's version) a test game with your macro worked that way. Edit: And Andreas beat me to it while I was testing!
1606229506
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yep, it's gonna be the spaces. Roll template fields are extremely precise in their naming requirements. They are case sensitive and space sensitive.
Removing the spaces seemed to fix it. I'm a dev, and have used handlebars before (the output templating engine), but it hadn't occurred to me that the way the parameters were being passed in would have an effect.&nbsp; Thanks everyone for your help!
1606236914
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
WillK said: Removing the spaces seemed to fix it. I'm a dev, and have used handlebars before (the output templating engine), but it hadn't occurred to me that the way the parameters were being passed in would have an effect.&nbsp; Thanks everyone for your help! You mean that you're using handlbars as the template language for coding your sheet? I just haven't gotten familiar enough with handlebars.
Sorry, I said that badly. I meant I have used handlebars in other projects. That's what Roll20 apparently uses for it's output templating.
What I find really weird about this situation is that template:default &nbsp;always works, even when there are spaces when passing the parameters in. With the custom templates, usually &nbsp;one of them works, but not all (and sometimes it's all or none). It's the inconsistency in the output that really threw me.
1606249551

Edited 1606249597
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, I won't pretend to know what templating language (if any) Roll20 uses for the template output, but I actually doubt that it's a full template language. As for why the default template works, it's because it is setup to output every template field that it receives. However, if you did something like the following you'd see the difference: &amp;{template:default} {{name=Duplicate fields}} {{result=[[1d20]]}} {{ result=[[1d10]]}} {{&nbsp; result=[[1d8]]}} vs &amp;{template:default} {{name=Duplicate fields}} {{result=[[1d20]]}} {{result=[[1d10]]}} {{result=[[1d8]]}} The first one will give you 3 (apparently identically labeled) result fields, while the 2nd one will only give you one visible result field that will show the roll from the third field only. Each of the result fields with spaces added counts as a new and unique field.
1606280767
vÍnce
Pro
Sheet Author
I should have noticed the leading space ie "{{ result=Dead }} {{ notes=Eaten by a groo }}" causing the issue... ;-( I always include allprops when adding roll templates.&nbsp; Works as a great "catch-all" for cases when someone adds an undefined key in a macro like {{ notes=foo}}&nbsp;
1606306892

Edited 1606311349
Andreas J.
Forum Champion
Sheet Author
Translator
∇ince said: I should have noticed the leading space ie "{{ result=Dead }} {{ notes=Eaten by a groo }}" causing the issue... ;-( When it comes to Roll20 macros, sheets &amp; the like, I usually go very much by the book on what is established to work, and avoid taking artistic liberties to any roll20-specific specific things with there on HTML/CSS/JS. So usually pay close attention to there changes that others might consider superficial or inconsequential: Case-sensitive, avoid spaces/linebreaks when possible, only use double-quotes in HTML/CSS etc. Having written the Restrictions -section of Building Char Sheets, I know Roll20 can be really fickle when it come to these things. Or maybe it's bc I'm superstitious and don't know how roll templates work, just follow the existing arcane rituals to shake them to life? :D I always include allprops when adding roll templates.&nbsp; Works as a great "catch-all" for cases when someone adds an undefined key in a macro like {{ notes=foo}} Yeah allprops is fine with having a space before the = sign, but seems predefined fields cannot have any leading space or it won't register. I just tried out the default roll template and having {{ name=Dexterity}} , which lead to the name-section being ignored, and Roll20 interpreting it as an allprops fields. I guess this needs to be added to the roll template documentation. Edit: I've updated few places related to roll templates, so this quirk is now documented, among things: Complete_Guide_to_Macros_%26_Rolls#Roll_Templates <a href="https://wiki.roll20.net/Roll_Templates" rel="nofollow">https://wiki.roll20.net/Roll_Templates</a> Split of Template creation to it's own page: Building_Character_Sheets/Roll_Templates
I've updated few places related to roll templates, so this quirk is now documented, among things: Thank you thank you thank you! You're a scholar and a gentleperson. I was going to request that it get added to the docs somewhere, since I really did read through them looking for a solution.&nbsp;