Skip to content

rikkertkoppes/module-stringtemplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

String template library

usage:

import { interpolate } from "StringTemplate";

interpolate("hello ${subject}", { subject: "world" });

The library interpolates stuff between ${ and }, much like other libraries. However, there are some additional operators, which makes it different than most and more like native JavaScript template strings (but without everything else that JavaScript can do)

You can also use array indices as part of the interpolation string

You can also skip array indices, in which case, the deeper values get mapped

available operators:

  • or operator eg: ${subject || 'fallback'}
  • ternary: ${bool? 'true': 'false'}
    expr = value (combinator value)*
    value = name | string | number
    name = ident ('.' ident)*
    combinator = ws? operator ws?
    operator = '||' | '?' | ':'

About

module-stringtemplate

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published