import { fmt } from "https://deno.land/x/grammy_parse_mode@1.10.0/format.ts";
This is the format tagged template function. It accepts a template literal
containing any mix of Stringable
and string
values, and constructs a
FormattedString
that represents the combination of all the given values.
The constructed FormattedString
also implements Stringable, and can be used
in further fmt
tagged templates.
Can also be called like regular function and passed an array of Stringable
s.
// Using return values of fmt in fmt
const left = fmt`${bold('>>>')} >>>`;
const right = fmt`<<< ${bold('<<<')}`;
const final = fmt`${left} ${ctx.msg.text} ${right}`;
await ctx.replyFmt(final);
// Using regular function form
const cart = fmt([
"Your shopping cart:\n",
...items.map((item) => fmt`- ${bold(item.name)} (${item.price})\n`),
]);
// Using result in editMessageText
await ctx.editMessageText(cart.text, { entities: cart.entities });
type
(rawStringParts: TemplateStringsArray | Stringable[], ...stringLikes: Stringable[]) => FormattedString