String interpolation in Typescript, replacing 'placeholders' with variables
Use a template string which are much better than String.Format
in my opinion as they do not suffer from poor indexing (wrong placeholder) issues:
var text = "blah blah";
var strTest = `This is a ${text}`;
console.log(strTest);
If I do not know the name of the variables I need to pass in??
Then wrap in a function e.g.
const gen = (text) => `This is a ${text}`;
I'd suggest using anonymous generator functions in your environments.ts
file, so you could pass the variables you need and have the template strings inside this functions. Something like this:
environments.ts
export const thisIsA = (str: string) => `This is a ${str}`;
Some other file:
import * as env from 'environments';
var text = "blah blah";
var strTest = env.thisIsA(text); //output: 'This is a blah blah'