#!/usr/bin/env dub
/+ dub.sdl:
name "styled-template"
dependency "sparkles:core-cli" path="../../.."
targetPath "build"
// Optimised, assertions live, `debug {}` blocks out — the build every nix
// artifact uses. Neither `debug` (which compiles those blocks in) nor
// `release` (which deletes assert *expressions*, side effects included).
buildType "checked" {
buildOptions "optimize" "inline" "debugInfo"
}
+/
module (module) styled_template_examplestyled_template_example;
import (package) sparklessparkles.(package) sparkles.basebase.(module) sparkles.base.styled_templateStyle template processing for IES (Interpolated Expression Sequences).
Provides a template syntax for applying terminal styles to IES strings:
import sparkles.base.styled_template;
int cpu = 75;
styledWriteln(i"CPU: {red $(cpu)%} Status: {green OK}");
Supported syntax:
{red text} — Apply single style
{bold.red text} — Chain multiple styles
{bold outer {red nested}} — Nested blocks (inner inherits outer)
{red text {~red normal}} — Negation with ~ removes a style
#{ — Escaped literal {
#} — Escaped literal }
styled_template;
import (package) sparklessparkles.(package) sparkles.uiui.(package) sparkles.ui.componentscomponents.(module) sparkles.ui.components.boxbox : (alias) styled_template_example.drawBox = string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox;
import (package) sparklessparkles.(package) sparkles.uiui.(package) sparkles.ui.componentscomponents.(module) sparkles.ui.components.demoDemo runner utilities for showcasing UI components.
Provides a structured way to display multiple sections with headers,
useful for examples and demonstrations.
demo : (struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section, (alias) styled_template_example.runDemo = void sparkles.ui.components.demo.runDemo(string header, sparkles.ui.components.demo.Section[] content, sparkles.ui.components.demo.DemoProps props = DemoProps(67LU, "Demo Complete")) @safeRuns a demo by printing a header banner, sections, and closing banner.
Example
runDemo(
header: "My Demo",
content: [
Section(header: "First", content: "Some content here"),
Section(header: "Second", content: "More content"),
],
);
runDemo;
void void D main()main()
{
void sparkles.ui.components.demo.runDemo(string header, sparkles.ui.components.demo.Section[] content, sparkles.ui.components.demo.DemoProps props = DemoProps(67LU, "Demo Complete")) @safeRuns a demo by printing a header banner, sections, and closing banner.
Example
runDemo(
header: "My Demo",
content: [
Section(header: "First", content: "Some content here"),
Section(header: "Second", content: "More content"),
],
);
Examples
Section initialization
const section = Section(header: "Title", content: "Body text");
assert(section.header == "Title");
assert(section.content == "Body text");
DemoProps defaults
const props = DemoProps.init;
assert(props.width == 67);
assert(props.endTitle == "Demo Complete");
runDemo(
header: "styledTemplate Demo - IES Style Syntax",
content: [
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Single Style",
content: [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{red This text is red}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{red This text is red}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{red This text is red}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{green This text is green}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{green This text is green}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{green This text is green}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{blue This text is blue}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{blue This text is blue}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{blue This text is blue}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{yellow This text is yellow}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{yellow This text is yellow}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{yellow This text is yellow}"),
].string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Colors"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Chained Styles",
content: [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold.red Bold and red}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold.red Bold and red}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold.red Bold and red}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{italic.cyan Italic and cyan}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{italic.cyan Italic and cyan}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{italic.cyan Italic and cyan}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{underline.magenta Underlined magenta}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{underline.magenta Underlined magenta}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{underline.magenta Underlined magenta}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold.italic.green Bold, italic, and green}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold.italic.green Bold, italic, and green}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold.italic.green Bold, italic, and green}"),
].string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Combined"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Text Attributes",
content: [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold Bold text}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold Bold text}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold Bold text}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{dim Dim text}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{dim Dim text}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{dim Dim text}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{italic Italic text}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{italic Italic text}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{italic Italic text}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{underline Underlined text}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{underline Underlined text}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{underline Underlined text}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{strikethrough Strikethrough text}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{strikethrough Strikethrough text}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{strikethrough Strikethrough text}"),
].string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Attributes"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Background Colors",
content: [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bgRed White on red}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bgRed White on red}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bgRed White on red}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bgGreen Black on green}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bgGreen Black on green}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bgGreen Black on green}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bgBlue White on blue}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bgBlue White on blue}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bgBlue White on blue}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bgYellow.black Black on yellow}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bgYellow.black Black on yellow}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bgYellow.black Black on yellow}"),
].string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Backgrounds"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Nested Blocks",
content: [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold Bold {red with red} back to bold}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold Bold {red with red} back to bold}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold Bold {red with red} back to bold}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{cyan Cyan {bold.underline bold underlined} just cyan}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{cyan Cyan {bold.underline bold underlined} just cyan}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{cyan Cyan {bold.underline bold underlined} just cyan}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{dim Dim {brightWhite bright} dim again}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{dim Dim {brightWhite bright} dim again}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{dim Dim {brightWhite bright} dim again}"),
].string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Nesting"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Style Negation",
content: [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold.red Bold red {~red just bold} bold red again}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold.red Bold red {~red just bold} bold red again}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold.red Bold red {~red just bold} bold red again}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{italic.underline Both {~italic underline only} both}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{italic.underline Both {~italic underline only} both}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{italic.underline Both {~italic underline only} both}"),
].string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Negation with ~"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Complex Combinations",
content: string[] styled_template_example.complexExamples()complexExamples().string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Advanced"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "With Interpolation",
content: string[] styled_template_example.interpolationExamples()interpolationExamples().string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Variables"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Escaped Braces",
content: [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"Use {{style text}} syntax for styling")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"Use {{style text}} syntax for styling" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"Use {{style text}} syntax for styling"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold Literal braces: {{these}} are not styles}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold Literal braces: {{these}} are not styles}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold Literal braces: {{these}} are not styles}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"JSON example: {{\"key\": \"value\"}}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"JSON example: {{\"key\": \"value\"}}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i`JSON example: {{"key": "value"}}`),
].string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Escaping"),
),
(struct) sparkles.ui.components.demo.SectionA section in a demo with a header and content.
Section(
header: "Practical Examples",
content: string[] styled_template_example.practicalExamples()practicalExamples().string sparkles.ui.components.box.drawBox(string[] content, string title, sparkles.ui.components.box.BoxProps props = BoxProps(false, null, null, null, null, null, 0LU, 0LU, TitleOverflow.expand, '\u256d', '\u256e', '\u2570', '\u256f', '\u2500', '\u2502', '\u257c', '\u257e', '\u2524', '\u251c'))drawBox("Real World"),
),
],
);
}
(alias) object.string = stringstring[] string[] styled_template_example.interpolationExamples()interpolationExamples()
{
int (local variable) int cpucpu = 75;
int (local variable) int memorymemory = 42;
(alias) object.string = stringstring (local variable) string statusstatus = "running";
double (local variable) double temperaturetemperature = 65.5;
return [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"CPU: {red ", core.interpolation.InterpolatedExpression!"cpu", int, core.interpolation.InterpolatedLiteral!"%}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"CPU: {red " __param_1, core.interpolation.InterpolatedExpression!"cpu" __param_2, int __param_3, core.interpolation.InterpolatedLiteral!"%}" __param_4, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"CPU: {red $(cpu)%}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"Memory: {green ", core.interpolation.InterpolatedExpression!"memory", int, core.interpolation.InterpolatedLiteral!"%}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"Memory: {green " __param_1, core.interpolation.InterpolatedExpression!"memory" __param_2, int __param_3, core.interpolation.InterpolatedLiteral!"%}" __param_4, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"Memory: {green $(memory)%}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"Status: {bold.cyan ", core.interpolation.InterpolatedExpression!"status", string, core.interpolation.InterpolatedLiteral!"}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"Status: {bold.cyan " __param_1, core.interpolation.InterpolatedExpression!"status" __param_2, string __param_3, core.interpolation.InterpolatedLiteral!"}" __param_4, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"Status: {bold.cyan $(status)}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"Temp: {yellow ", core.interpolation.InterpolatedExpression!"temperature", double, core.interpolation.InterpolatedLiteral!"}C")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"Temp: {yellow " __param_1, core.interpolation.InterpolatedExpression!"temperature" __param_2, double __param_3, core.interpolation.InterpolatedLiteral!"}C" __param_4, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"Temp: {yellow $(temperature)}C"),
];
}
(alias) object.string = stringstring[] string[] styled_template_example.complexExamples()complexExamples()
{
return [
// Deep nesting: 4 levels with style changes at each
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold.italic.red L1:{~red.underline L2:{cyan L3:{~bold.~italic L4}L3}L2}L1}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold.italic.red L1:{~red.underline L2:{cyan L3:{~bold.~italic L4}L3}L2}L1}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold.italic.red L1:{~red.underline L2:{cyan L3:{~bold.~italic L4}L3}L2}L1}"),
// Multiple negations then restore
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold.italic.underline ALL {~bold.~underline just italic} ALL again}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold.italic.underline ALL {~bold.~underline just italic} ALL again}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold.italic.underline ALL {~bold.~underline just italic} ALL again}"),
// Negation combined with addition
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold.red start {~red.cyan swap colors} back to red}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold.red start {~red.cyan swap colors} back to red}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold.red start {~red.cyan swap colors} back to red}"),
// Three-level nesting with additions
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{red outer {bold middle {underline.cyan inner} middle} outer}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{red outer {bold middle {underline.cyan inner} middle} outer}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{red outer {bold middle {underline.cyan inner} middle} outer}"),
// Style accumulation through levels
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold B {italic BI {underline BIU {red BIUR} BIU} BI} B}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold B {italic BI {underline BIU {red BIUR} BIU} BI} B}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold B {italic BI {underline BIU {red BIUR} BIU} BI} B}"),
// Toggle effect: remove and re-add
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{bold.red on {~bold off {bold on} off} on}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{bold.red on {~bold off {bold on} off} on}" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{bold.red on {~bold off {bold on} off} on}"),
];
}
(alias) object.string = stringstring[] string[] styled_template_example.practicalExamples()practicalExamples()
{
(alias) object.string = stringstring (local variable) string errorMsgerrorMsg = "Connection refused";
(alias) object.string = stringstring (local variable) string filenamefilename = "config.json";
int (local variable) int lineline = 42;
int (local variable) int errorserrors = 3;
int (local variable) int warningswarnings = 7;
return [
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{red.bold ERROR:} ", core.interpolation.InterpolatedExpression!"errorMsg", string)(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{red.bold ERROR:} " __param_1, core.interpolation.InterpolatedExpression!"errorMsg" __param_2, string __param_3, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{red.bold ERROR:} $(errorMsg)"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{yellow WARNING:} Deprecated API usage")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{yellow WARNING:} Deprecated API usage" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{yellow WARNING:} Deprecated API usage"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{green.bold SUCCESS:} Build completed")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{green.bold SUCCESS:} Build completed" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{green.bold SUCCESS:} Build completed"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"{dim ", core.interpolation.InterpolatedExpression!"filename", string, core.interpolation.InterpolatedLiteral!":", core.interpolation.InterpolatedExpression!"line", int, core.interpolation.InterpolatedLiteral!"} - {red ", core.interpolation.InterpolatedExpression!"errors", int, core.interpolation.InterpolatedLiteral!" errors}, {yellow ", core.interpolation.InterpolatedExpression!"warnings", int, core.interpolation.InterpolatedLiteral!" warnings}")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"{dim " __param_1, core.interpolation.InterpolatedExpression!"filename" __param_2, string __param_3, core.interpolation.InterpolatedLiteral!":" __param_4, core.interpolation.InterpolatedExpression!"line" __param_5, int __param_6, core.interpolation.InterpolatedLiteral!"} - {red " __param_7, core.interpolation.InterpolatedExpression!"errors" __param_8, int __param_9, core.interpolation.InterpolatedLiteral!" errors}, {yellow " __param_10, core.interpolation.InterpolatedExpression!"warnings" __param_11, int __param_12, core.interpolation.InterpolatedLiteral!" warnings}" __param_13, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"{dim $(filename):$(line)} - {red $(errors) errors}, {yellow $(warnings) warnings}"),
string sparkles.base.styled_template.styledText!(core.interpolation.InterpolatedLiteral!"Press {bold.cyan q} to quit, {bold.cyan h} for help")(core.interpolation.InterpolationHeader header, core.interpolation.InterpolatedLiteral!"Press {bold.cyan q} to quit, {bold.cyan h} for help" __param_1, core.interpolation.InterpolationFooter footer) nothrow @safeditto — defaults to ColorDepth.trueColor (no folding).
styledText(i"Press {bold.cyan q} to quit, {bold.cyan h} for help"),
];
}