# Static format string (scripty)

**URL:** <https://zine.discourse.group/t/static-format-string-scripty/57>\
**Category:** Help\
**Created:** [August 19, 2026, 6:19pm UTC](https://zine.discourse.group/t/static-format-string-scripty/57 "2026-08-19T18:19:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eamonburns](https://yyz2.discourse-cdn.com/flex052/user_avatar/zine.discourse.group/eamonburns/32/81_2.png) [@eamonburns](https://zine.discourse.group/u/eamonburns)\
**Post date:** [August 19, 2026, 6:19pm UTC](https://zine.discourse.group/t/static-format-string-scripty/57/1 "2026-08-19T18:19:55Z")

</div>

I would like to create a formatted string with a static format:

In Zig, it would be:

```rust
print("Hello ({})", .{name});

```

My first attempt was this:

```xml
<p :text="'Hello ({})'.fmt($ctx.name)"></p>

```

But that wasn’t started with a `$`, so obviously it didn’t work. Second attempt:

```xml
<p :text="$'Hello ({})'.fmt($ctx.name)"></p>

```

Doesn’t work (expected a variable name).

I had to fallback to my original version (which is _kind of_ ok for this case, but would get very unwieldy for format strings with more placeholders):

```xml
<p :text="$ctx.name.prefix('Hello (').suffix(')')"></p>

```

Is there a way to do this? Maybe call `String.fmt('Hello ({})', $ctx.name)` directly?

---

<div class="post-metadata">

**Author:** ![jcpsantiago](https://yyz2.discourse-cdn.com/flex052/user_avatar/zine.discourse.group/jcpsantiago/32/113_2.png) [@jcpsantiago](https://zine.discourse.group/u/jcpsantiago)\
**Post date:** [October 30, 2026, 7:35pm UTC](https://zine.discourse.group/t/static-format-string-scripty/57/2 "2026-10-30T19:35:04Z")

</div>

I am looking for a way to do this too 🙂

To avoid an XY problem, what I’m trying to achieve is changing the color used in an inline style e.g., `style="border-color: var(--{});"`because each element in a loop is supposed to get a different color and I don’t want to write a different class just for this.

I also want to add different classes e.g., `class="base-class {}"` .

It sounds like this can only work if I define these “base strings” somewhere else e.g., `ziggy.zine` , then bind them in `ctx` and format with the data coming in from the loop?

---

<div class="post-metadata">

**Author:** ![jcpsantiago](https://yyz2.discourse-cdn.com/flex052/user_avatar/zine.discourse.group/jcpsantiago/32/113_2.png) [@jcpsantiago](https://zine.discourse.group/u/jcpsantiago)\
**Post date:** [November 2, 2026, 9:14am UTC](https://zine.discourse.group/t/static-format-string-scripty/57/3 "2026-11-02T09:14:47Z")

</div>

I think this [Appropriate way to build a string in scripty - #3 by richardlehane](https://zine.discourse.group/t/appropriate-way-to-build-a-string-in-scripty/16/3) answers the question.

What I’m doing right now is to add the “base string” with the classes I always want as a variable in `page.custom` and then work with it `$page.custom.get(‘my-base-string’).suffix(‘more-stuff’)`.
