OpenStore Feedback Add your apps

Search OpenStore

Find an app or a developer

str_template icon

str_template

Tiny string templating library for JavaScript and TypeScript. Fill placeholders like {name} in a string from an object, in Node or the browser

p32929Developer ToolsString templateTemplatingString formatTypeScriptJavaScriptNode.jsBrowsernpm Website Source code
Install
Platform
Libraries
Category
Developer Tools
Available from
npm

About this app

str_template is a tiny string templating library for JavaScript and TypeScript. When a message or text comes from a file, a database or a translation, you can't use a template literal, and joining strings by hand gets ugly. Write {placeholders} in the string and fill them from an object with one call.

I made it because I needed a small string templating tool. The others out there pretty much all do the same thing, so I thought: okay, let's make my own as well.

  1. One function: StrTemplate.format(text, values).
  2. Your own separator: use {} by default, or something like [[ ]] if braces are already in your text.
  3. Works the same in Node.js and the browser.
  4. Written in TypeScript, small and fast.

Great for message templates, emails and any text with values filled in later.

Install

npm install str-template-ts
StrTemplate.format('Hello {name}!', { name: 'Fayaz' }) // Hello Fayaz!

Want help tidying up how your app handles text and messages? Contact me through my portfolio: https://p32929.github.io

More from Fayaz Bin Salam

See all 87