Currently, if you want to do custom roll templates/css that you use in your API, then you are forced to switch your character sheet to Custom and copy in the html and css from the character sheet source so that you can add your own custom stuff to it. This means that the character sheet will not be automagically updated when the source is, and you have to manage it yourself. I would like to propose that a new section be added to the "API Scripts" page that mimics the interface we get when we use a Custom Character sheet (ie. HTML Layout/CSS Styling). Within this new section API writers can define/maintain custom Roll Templates and CSS. This would allow us to use the built-in character sheets that are automagically maintained, and still have custom html/css to use in the APIs. For extra credit, you can give us an API that will allow script writers to Create/Read/Update with these custom Roll Templates/CSS so that users of the scripts don't have to maintain them. Examples:
function InitializeRollTemplate() {
var rollTemplate = getObj("rollTemplate", "myNamespace-myRollTemplate"); if(rollTemplate === null) { createObj("rollTemplate", { name: "myNamespace-myRollTemplate", version: 1, template: sMyTemplateHtml }); } var myCss = getObj("css", "#myNamespace-Version"); if( (myCss === null) || (myCss.font_size !== 2 /* current version */) ) { // createObj would add/replace the css styles mapped to the selector specified // any property in the style object other than "selector", just turn into a css property with '_' replaced with '-' createObj("css", { styles: [ { selector: "#myNamespace-Version", font_size: 2 /* Uses font-size as the version */ }, { selector: ".myNamespace-Class1, .myNamespace-Class2, #myNamespace_Object1", font_weight: "bold", background_color: "green" } ] }); } } Now in our API we can just use the roll template like we normally use them, and magic happens... Of course this means that someone could do malicious/unintended damage to your custom roll templates/css. However based on the 90/10 rule, I don't think there are very many Roll20 API writers that are going intentionally do something malicious. Most of them are sharing their scripts to help. Unintended things will happen. Proper namespace standards will help prevent it, but even when it doesn't you already have disclaimers all over the place telling us to test the APIs in a copy of our games before using them in a real game. In my opinion, these ideas are "safe enough" for this community.