New:Socket for Asana Is Now Available.Learn more
Get Started

tlsp

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tlsp

A lightweight JavaScript template string library with zero third-party dependencies

latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

Tlsp

简体中文
A lightweight JavaScript template string library with zero third-party dependencies

  • Entire codebase < 1kb
  • Supports function calls, numeric calculations, and other operations just like in JavaScript
  • Allows custom template string formats (supports wildcards)
  • Environmentally secure—by default, template strings cannot access Node.js's require function

Examples

var TemplateString = require("tlsp")  

// Quick Start  
var result = TemplateString.templateString(  
 "Member Data ----- \  
  \nName: ${ name.split(' ').join('-') } \  
  \nAge: ${ getAge() } \  
  \nSex: ${ boy ? 'boy' : 'girl' }", {  
    name: "Any Body",  
    boy: true,  
    getAge: () => 114514  
  }  
)  

console.log(result)  
console.log("")  

// Custom  
var tlsp = new TemplateString  
tlsp.format = "<?node*?>"  
tlsp.context = {  
  apple: {  
    en: "Apple",  
    zh: "林檎("  
  },  
  lang: "zh"  
}  
result = tlsp.generate("lang.apple.name = <?node apple[lang] ?>")  
console.log(result);  

Keywords

template

FAQs

Package last updated on 07 Aug 2025

Related posts