Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on Jun 1, 2024 via pnpm

string-template 1.0.0

A simple string template function based on named or indexed arguments
Package summary
Share
0
issues
1
license
1
MIT
Package created
30 Sep 2013
Version published
7 Jan 2016
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
string-template@1.0.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of string-template 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does string-template do?

String-Template is a simple JavaScript utility that aids developers in formatting strings. It operates based on named or indexed arguments, thereby allowing for dynamic insertion of values into a pre-defined string format or template. This flexibility enhances code readability and maintenance.

How do you use string-template?

To use this utility in your JavaScript project, first, install it via npm (Node Package Manager) with the command npm install string-template. The main string-template function can be used in several ways including:

  1. Formatting with an object hash:
var format = require("string-template");
var greeting = format("Hello {name}, you have {count} unread messages", {
    name: "Robert",
    count: 12
});
// Output: "Hello Robert, you have 12 unread messages"
  1. Formatting with an indexed array or using optional arguments:
var greeting = format("Hello {0}, you have {1} unread messages", ["Robert", 12]);
// Output: "Hello Robert, you have 12 unread messages"
  1. If you need performance, it exposes two template compiling options. Here is how to use them:
var compile = require("string-template/compile")
var greetingTemplate = compile("Hello {0}, you have {1} unread messages")
var greeting = greetingTemplate("Robert", 12)
// Output: "Hello Robert, you have 12 unread messages"

Simply replace the keys (like {name} or {0}) with your desired values in the string and you're good to go!

Where are the string-template docs?

The documentation for the string-template package is implicitly available within the README file on the package's GitHub repository found at github.com/Matt-Esch/string-template. Here, you will find comprehensive examples, usage instruction, and other relevant information about string-template.