0.0.4 • Published 7 months ago

@dtyq/es6-template-strings v0.0.4

Weekly downloads
-
License
Apache License 2....
Repository
github
Last release
7 months ago

@dtyq/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 "@dtyq/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

OptionDescriptionTypeDefaultRequired
notationTemplate syntax prefixstring"$"No
notationStartTemplate syntax start markerstring"{"No
notationEndTemplate syntax end markerstring"}"No
partialSkip failed expressions instead of returning undefinedbooleanfalseNo

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
  • The package handles nested expressions and escape sequences properly

Development

To set up the development environment:

  1. Clone the repository
  2. Install dependencies: npm install
  3. Build the package: npm run build
  4. Run tests: npm test

Iteration Process

The package follows semantic versioning:

  1. Bug fixes result in patch version increments
  2. New features that maintain backward compatibility result in minor version increments
  3. Breaking changes result in major version increments

For contributing: 1. Fork the repository 2. Create a feature branch 3. Submit a pull request with detailed description of changes

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago