2025-10-02 10:15:38 -05:00
|
|
|
import { assertSecret } from "@blitzkit/core";
|
|
|
|
|
|
|
|
|
|
const dev = assertSecret(import.meta.env.DEV);
|
|
|
|
|
|
2025-10-01 22:41:23 -05:00
|
|
|
export function literals(
|
|
|
|
|
string: string,
|
2025-10-02 10:15:38 -05:00
|
|
|
literals?: Record<string, string | number | undefined>
|
2025-10-01 22:41:23 -05:00
|
|
|
) {
|
|
|
|
|
for (const key in literals) {
|
2025-10-02 10:15:38 -05:00
|
|
|
const mutated = string.replaceAll(`{${key}}`, `${literals[key]}`);
|
|
|
|
|
|
|
|
|
|
if (dev && mutated === string) {
|
|
|
|
|
console.warn(`Could not find literal {${key}} in string "${string}"`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string = mutated;
|
2025-10-01 22:41:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return string;
|
2025-01-06 20:09:11 -06:00
|
|
|
}
|