Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Editing Templates

David Carver edited this page Feb 6, 2017 · 5 revisions

Template Location

Starting with XStreamer v.0.3.0, the templates can now be found in the following directory:

plugins/us.nineworlds.xstreamer.templates/templates

The templates directory may have the version number of xstreamer appended to it, so please make sure you are updating the correct one.

Directory structure

The directory structure has changed starting with v0.3.0.

templates
   squads
       html
       text
   dice
       html
       text

Under the sub-directories html and text are the corresponding freemarker templates. HTML templates generate HTML output and can be used with the OBS Browser plugin. Text templates generate straight text files and can be used with the Text Source plugin. If you have developed your own templates it is recommended to place them in the appropriate structures.

If you feel like contributing your templates to the project please consider opening an Issue and attaching them to the the issue.

Including and Importing Templates

Templates can import and include other templates. Including is like a copy and paste operation, and Imports put the code into a namespace that can be referenced.

The correct syntax for the include statement is as follows:

<#include "path/to/file/to/be/included"/>

Note: This is relative to the file that is doing the including.

How to Edit Templates Online

http://freemarker-online.kenshoo.com/

There is a web site that can be used to help create and validate templates that are used with XStreamer. Since XStreamer makes use of the XWS Spec you can output any squad in this format and setup the data model for the Online Freemarker Editor as below.

The program is pretty basic but it does give a way to evaluate and help create your templates.

Sample Template

<html>
<head>
  <style>
    body { margin: 5px;
           color: #F8F8FF;
           text-shadow: 4px 1px #000000;
           text-align: right;
         }

    .squad { padding:5px;
             background-image: linear-gradient(rgba(0, 0, 0, 0.5),rgba(0, 0, 0, 0.5)); 
         }
    .pilot { font-size: 14pt; margin-botton: 2px;}
    .shields { font-size: 14pt; color: cyan; }
    .hull { font-size: 14pt; color: yellow; }
  </style>
</head>
<body>
<#list xwsspec.pilots as pilot>
<div class="squad">
<b class="pilot">${pilot.name} (${pilot.points})</b><br/>
<b class="shields">${(pilot.shields)!"0"}</b> <image style="vertical-align: middle;" height="30" width="30" src="images/Token_Shield.png"/>&nbsp;&nbsp;
<b class="hull">${(pilot.hull)!"0"}</b><image style="vertical-align: middle;" height="30" width="30"src="images/Token_Hull.png"/>
<br/>
</div>
</#list>

</body>
</html>

Sample Data Model


xwsspec = {"description":"","faction":"rebel","name":"Close Proximity","pilots":[{"name":"goldsquadronpilot","points":24,"ship":"ywing","upgrades":{"turret":["ioncannonturret"],"amd":["r2astromech"]}},{"name":"goldsquadronpilot","points":24,"ship":"ywing", "shields":"0", "hull":"0","upgrades":{"turret":["ioncannonturret"],"amd":["r2astromech"]}},{"name":"goldsquadronpilot","points":26,"ship":"ywing", "shields":"0", "hull":"0", "upgrades":{"turret":["autoblasterturret"],"torpedo":["extramunitions","bombloadout"],"amd":["r2astromech"],"bomb":["proximitymines"]}},{"name":"goldsquadronpilot","points":26,"ship":"ywing", "shields":"0", "hull":"0","upgrades":{"turret":["autoblasterturret"],"torpedo":["extramunitions","bombloadout"],"amd":["r2astromech"],"bomb":["proximitymines"]}}],"points":100,"vendor":{"yasb":{"builder":"(Yet Another) X-Wing Miniatures Squad Builder","builder_url":"https://geordanr.github.io/xwing/","link":"https://geordanr.github.io/xwing/?f=Rebel%20Alliance&d=v4!s!9:0,-1,-1,2:-1:-1:;9:0,-1,-1,2:-1:-1:;9:120,126,116,2:-1:-1:U.28;9:120,126,116,2:-1:-1:U.28&sn=Close%20Proximity"}},"version":"0.3.0"}

Sample Pilot and Ship Data

TODO