Skip to content

Commit 373de17

Browse files
committed
Improve template readme
Signed-off-by: Marc Edwards <[email protected]>
1 parent b41a829 commit 373de17

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

pinwheel/templates/readme.md

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
Pinwheel’s [exporting](/help/pinwheel/exporting/) supports a wide range of common formats. If you need a format we don’t support, a custom template can be used.
1+
Pinwheel’s [exporting](https://bjango.com/help/pinwheel/exporting/) supports a wide range of common formats. If you need a format we don’t support, a custom template can be used.
22

3-
Custom templates use the [Stencil template language](https://stencil.fuller.li/en/latest/templates.html).
3+
Custom templates use the [Stencil template language](https://stencil.fuller.li/en/latest/templates.html). Most of Pinwheel’s built-in exporting uses Stencil templates, and are available in our [Bjango DevKit GitHub repository](https://github.com/bjango/Bjango-DevKit/tree/main/pinwheel/templates/Pinwheel%20Built%20In%20Examples). Feel free to use them as the basis of your own templates, or to learn how templates work.
44

5-
The data structure availble in templates is a list of `items` at the top level. There is also a `exportFileName` item that corresponds to the file name in the build task. You can iterate through all the items like this:
5+
6+
### Main structure
7+
8+
The data structure available in templates is a list of `items` at the top level. There is also a `exportFileName` item that corresponds to the file name in the build task. You can iterate through all the items like this:
69

710
```
811
{% for item in items %}
@@ -20,6 +23,9 @@ And, if you wanted to see if it is a number, you'd use:
2023
{% if item.number %}
2124
```
2225

26+
27+
### Appearance, contrast, and color formatters
28+
2329
A `colorItem` has a `color` which can have `light`, `dark`, `highContrast` and `darkHighContrast` appearances. If a color has no appearances, then only the `light` value will be set. You can access it like this:
2430

2531
```
@@ -29,20 +35,20 @@ A `colorItem` has a `color` which can have `light`, `dark`, `highContrast` and `
2935
The formatter above is a custom tag. There are lots of format options available for colors. They correspond to all the formats you can use in the Pinwheel color picker:
3036

3137
```
32-
colorAsFloatRGBA,
38+
colorAsFloatRGBA,
3339
colorAsFloatHSVA,
34-
colorAsCSSHexRGB,
35-
colorAsCSSRgb,
36-
colorAsCSSColor,
40+
colorAsCSSHexRGB,
41+
colorAsCSSRgb,
42+
colorAsCSSColor,
3743
colorAsCSSOklch,
38-
colorAsHex,
39-
colorAsHexRGBA,
44+
colorAsHex,
45+
colorAsHexRGBA,
4046
colorAsHexARGB,
41-
colorAsSwiftUIColor,
42-
colorAsSwiftUIKitColor,
43-
colorAsSwiftAppKitColor,
44-
colorAsSwiftUIColorHSBA,
45-
colorAsSwiftUIKitColorHSBA,
47+
colorAsSwiftUIColor,
48+
colorAsSwiftUIKitColor,
49+
colorAsSwiftAppKitColor,
50+
colorAsSwiftUIColorHSBA,
51+
colorAsSwiftUIKitColorHSBA,
4652
colorAsSwiftAppKitColorHSBA
4753
```
4854

@@ -55,6 +61,9 @@ There are 3 parameters to this formatter, the first two are required, the last i
5561
2. The dark color you want to use
5662
3. The CSS format you want these colors to be output in. This can be `cssHex` (eg: `#FFFFFF`), `cssRgb` (eg: `rgb(255, 255, 255)`), `cssColor` (eg: `color(srgb 1 1 1)`) or `cssOKLCH` (eg: `oklch(100.0% 0.0 89.9 / 1.0)`). If none is specified `cssColor` will be used.
5763

64+
65+
### Code safe names
66+
5867
There is also a formatter for creating safe variable names in most programming languages (things like making sure it doesn't start with a number, removing spaces, etc):
5968
```
6069
codeSafeName
@@ -74,6 +83,9 @@ You can combine multiple formatters, for example say you wanted to create a Swif
7483
let {%+ codeSafeName color.name +%} = {%+ colorAsSwiftUIColor color.light +%}
7584
```
7685

86+
87+
### Numbers, strings, and booleans
88+
7789
For `number`, `string` and `boolean` types you can access the `value` of each in a similar way:
7890

7991
```
@@ -97,6 +109,9 @@ This item is called Green.
97109
This item is called Important.
98110
```
99111

112+
113+
### Full example
114+
100115
The full data structure is below for the technically minded:
101116

102117
```swift

0 commit comments

Comments
 (0)