Library API
    Preparing search index...

    Function makeTemplate

    • Interpolates an object's values into a Template Literal string containing ${key} placeholders.

      Parameters

      • templateString: any

        The string containing ${key} placeholders

      Returns (templateData: any) => string

      A function that takes a data object and returns the interpolated string

      WARNING: Should not be used with untrusted templateString inputs if any form of evaluation is expected. This implementation only supports simple ${key} substitutions from templateData.

      const greet = makeTemplate('Hello ${name}');
      greet({ name: 'World' }); // 'Hello World'