Skip to content

vanillaes/interpolate

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Interpolate

A small, easy-to-use template literal builder. Good for loading template literal strings from external sources.

GitHub Release NPM Release Bundlephobia Latest Status Release Status

Discord

Features

  • ECMAScript Module
  • Typescript Compatible
  • Tiny Footprint (1K)

Imports

This package works isomorphically in browser and server-side JavaScript

Browser

Import directly from the local path or a CDN

<script type="module">
import { interpolate } from 'path/to/interpolate/index.js'
</script>

The minified version can be imported from

<script type="module">
import { interpolate } from 'path/to/interpolate/index.min.js'
</script>

Node

Install the package

npm install @vanillaes/interpolate

Import using the module path

import { interpolate } from '@vanillaes/interpolate'

Interpolate()

Builds a string from a template string + tags collection.

Arguments

Interpolate(template, {tags})

  • template - the template literal string
  • tags - the tagged values in the template

Typings

Typings are generated from JSDoc using Typescript. They are 100% compatible with VSCode Intellisense and will work seamlessly with Typescript.