Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stringtemplate4ts

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stringtemplate4ts

A TypeScript port of the Java StringTemplate 4 library

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

GitHub Workflow Status (with event) Weekly Downloads npm version

Introduction

This repository contains a TypeScript port of the StringTemplate 4 template engine. It's released under the BSD license, like the original code, plus some additional code, which is released under the MIT license. These are:

  • Testing infrastructure code (decorators, JUnit wrappers, configuration and spec files)
  • A MurmurHash implementation used by the HashMap class.
  • The HashMap class.

ST4TS (StringTemplate4TypeScript) is a template engine for generating source code, web pages, emails, or any other formatted text output. ST4TS is particularly good at multi-targeted code generators, multiple site skins, and internationalization/localization.

The main website for the original ST implementation is:

https://www.stringtemplate.org

Its distinguishing characteristic is that it strictly enforces model-view separation, unlike other engines. See this document

The documentation is here

Per the BSD license in LICENSE.txt, this software is not guaranteed to work and might even destroy all life on this planet.

Known Differences

The port closely resembles the original. Luckily, Java and TypeScript share many similarities, allowing for the implementation of even esoteric language features such as runtime method access and invocation using string names (also known as reflection). However, there are a few differences, which are listed below:

  • Importing modules is different in both languages and can be challenging when dealing with circular dependencies. To avoid these dependencies, interfaces and factory methods have been defined for certain classes that refer to each other. This should not impose any restrictions for normal usage.
  • Formatting numbers with arbitrary format strings and locale support is not available. We can either have locale aware formatting using the standard toLocaleString method or we can have a custom format string pattern, not both. I decided for the latter (which uses the fast-printf library). Once I have found a library which supports both (such as luxon for date and time), this can be improved.

Installation

Run

npm i stringtemplate4ts

Or use your preferred package manager.

Building from Source

The source is at github.com:

https://github.com/mike-lischke/stringtemplate4ts

Check the repository out and run

npm run build

in the project root.

Running Unit Tests

Running the tests is equally simple. Just do:

npm run test

in the project root.

Release Notes

1.0.3

  • Fixed a bug where members of model objects, which are themselves object were not accessible in templates. Added a test case for that.

1.0.2

  • Upgraded dependencies to latest versions.
  • Added export for common interfaces.

1.0.0 - 1.0.1

  • Initial release.
  • Changed build structure to include both CommonJS and ES6 modules.

Keywords

FAQs

Package last updated on 16 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc