@bedelightful/es6-template-strings
v0.0.5
Published
Template string engine
Readme
@bedelightful/es6-template-strings
ES6 Template Strings Parser Engine
Overview
This package provides a template string parsing engine that supports ES6-style syntax. It allows you to interpolate variables and expressions within strings using the ${expression} syntax.
Usage
import { resolveToString, resolveToArray } from "@delightful/es6-template-strings";
// Basic usage
console.log(resolveToString("hello ${name}", { name: "world" }));
// Output: "hello world"
// Return array of template parts and substitutions
console.log(resolveToArray("hello ${name}", { name: "world" }));
// Output: ["hello ", "world"]Configuration Options
| Option | Description | Type | Default | Required | |:------:|:----------:|:----:|:-------:|:--------:| | notation | Template syntax prefix | string | "$" | No | | notationStart | Template syntax start marker | string | "{" | No | | notationEnd | Template syntax end marker | string | "}" | No | | partial | Skip failed expressions instead of returning undefined | boolean | false | No |
Notes
- When an expression cannot be resolved:
- If
partial: true, the original${expression}string will be preserved - If
partial: false(default), undefined will be returned for that expression
- If
- The package handles nested expressions and escape sequences properly
Development
To set up the development environment:
- Clone the repository
- Install dependencies:
npm install - Build the package:
npm run build - Run tests:
npm test
Iteration Process
The package follows semantic versioning:
- Bug fixes result in patch version increments
- New features that maintain backward compatibility result in minor version increments
- Breaking changes result in major version increments
For contributing:
- Fork the repository
- Create a feature branch
- Submit a pull request with detailed description of changes
