Skip to content

Commit 62e8aa5

Browse files
committed
Add 16bit rgb context values for mustache templates
1 parent c70ff21 commit 62e8aa5

File tree

8 files changed

+46
-7
lines changed

8 files changed

+46
-7
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [0.11.0] - 2024-09-07
4+
5+
## Added
6+
7+
- Add support for proposed 0.12.0 builder spec by adding 16bit rgb
8+
colour variables to the mustache context
9+
310
## [0.10.1] - 2024-09-03
411

512
## Fixed
@@ -169,6 +176,7 @@
169176
- `sync` subcommand support to sync with latest Tinted Theming schemes
170177
- `build` subcommand to trigger theme template build
171178

179+
[0.11.0]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.10.1...v0.11.0
172180
[0.10.1]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.10.0...v0.10.1
173181
[0.10.0]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.9.5...v0.10.0
174182
[0.9.5]: https://github.com/tinted-theming/tinted-builder-rust/compare/v0.9.3...v0.9.5

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

THIRD_PARTY_LICENSES.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1683,8 +1683,8 @@ limitations under the License.
16831683

16841684
#### Used by
16851685

1686-
- [tinted-builder 0.6.0](https://github.com/tinted-theming/tinted-builder-rust)
1687-
- [tinted-builder-rust 0.10.1](https://github.com/tinted-theming/tinted-builder-rust)
1686+
- [tinted-builder 0.7.0](https://github.com/tinted-theming/tinted-builder-rust)
1687+
- [tinted-builder-rust 0.11.0](https://github.com/tinted-theming/tinted-builder-rust)
16881688
- [ribboncurls 0.2.1](https://github.com/tinted-theming/ribboncurls)
16891689

16901690
```

tinted-builder-rust/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tinted-builder-rust"
3-
version = "0.10.1"
3+
version = "0.11.0"
44
edition = "2021"
55
authors = ["Jamy Golden <[email protected]>", "Tinted Theming <[email protected]>"]
66
license = "MIT OR Apache-2.0"
@@ -24,7 +24,7 @@ strip-ansi-escapes = "0.2.0"
2424

2525
[dependencies.tinted-builder]
2626
path = "../tinted-builder"
27-
version = "0.6.0"
27+
version = "0.7.0"
2828

2929
[[bin]]
3030
name = "tinted-builder-rust"

tinted-builder/CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 0.7.0 - 2024-09-07
4+
5+
## Added
6+
7+
- Add support for proposed 0.12.0 builder spec by adding 16bit rgb
8+
colour variables to the mustache context
9+
310
## 0.6.0 - 2024-08-28
411

512
## Added

tinted-builder/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tinted-builder"
33
description = "A Tinted Theming template builder which uses yaml color schemes to generate theme files."
4-
version = "0.6.0"
4+
version = "0.7.0"
55
edition = "2021"
66
license = "MIT OR Apache-2.0"
77
readme = "README.md"

tinted-builder/src/template/base16.rs

+12
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ pub(crate) fn to_template_context(scheme: &Base16Scheme) -> HashMap<String, Stri
5454
context.insert(format!("{}-rgb-r", name), rgb.0.to_string());
5555
context.insert(format!("{}-rgb-g", name), rgb.1.to_string());
5656
context.insert(format!("{}-rgb-b", name), rgb.2.to_string());
57+
context.insert(
58+
format!("{}-rgb16-r", name),
59+
(rgb.0 as u16 * 257_u16).to_string(),
60+
);
61+
context.insert(
62+
format!("{}-rgb16-g", name),
63+
(rgb.1 as u16 * 257_u16).to_string(),
64+
);
65+
context.insert(
66+
format!("{}-rgb16-b", name),
67+
(rgb.2 as u16 * 257_u16).to_string(),
68+
);
5769
context.insert(
5870
format!("{}-dec-r", name),
5971
format!("{:.8}", rgb.0 as f64 / 255.),

tinted-builder/tests/general.rs

+12
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,18 @@ fn render_rgb() -> Result<()> {
139139
Ok(())
140140
}
141141

142+
#[test]
143+
fn render_rgb16() -> Result<()> {
144+
let template_source = "{{base0A-rgb16-r}} {{base0A-rgb16-g}} {{base0A-rgb16-b}}";
145+
let scheme = Scheme::Base16(serde_yaml::from_str(SCHEME_SILK_LIGHT)?);
146+
let template = Template::new(template_source.to_string(), scheme);
147+
148+
let output = template.render()?;
149+
150+
assert_eq!(output, "53199 44461 9509");
151+
Ok(())
152+
}
153+
142154
#[test]
143155
fn render_dec() -> Result<()> {
144156
let template_source = "{{base0A-dec-r}} {{base0A-dec-g}} {{base0A-dec-b}}";

0 commit comments

Comments
 (0)