escape-delims
Escape and un-escape delimiters in templates. Tested with Lo-Dash, underscore and Handlebars syntax, but could be used with other template engines/syntaxes as well. This is similar to the process used by Yeoman on escaped templates in generators.
Last updated 11 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install escape-delims 
SYNC missed versions from official npm registry.

escape-delims NPM version

Escape and un-escape delimiters in templates. Tested with Lo-Dash, underscore and Handlebars syntax, but could be used with other template engines/syntaxes as well. This is similar to the process used by Yeoman on escaped templates in generators.

Install

Install with npm:

npm i escape-delims --save-dev

Usage

var EscapeDelims = require('escape-delims');

API

EscapeDelims

Create a new instance of EscapeDelims():

  • from {Array}: Optionally pass delimiters to use for escaping. Defaults to ['{%%', '%}'].
  • to {Array}: Optionally pass delimiters to use for un-escaping. Defaults to ['{%%', '%}'].
var EscapeDelims = require('escape-delims');
var escapeDelims = new EscapeDelims();

Optionally pass the "escape delimiters" to use as an array:

var escapeDelims = new EscapeDelims(['<%%', '%>']);

.escape

Escape the given str, optionally passing a delimiter syntax to use if not defined in the constructor.

  • str {String}: The string with delimiters to escape.
  • from {Array}: The delimiter syntax to use.

Example:

escapeDelims.escape('<%%= first %><%= last %>', ['<%%', '%>']);
//=> '(;^__^;) first (;\^_\^;)<%= last %>'

.unescape

Un-escape previously escaped delimiters in the given str. Optionally pass the syntax to use if they have not already been defined.

  • str {String}: The string with delimiters that need to be escaped.
  • to {Array}: The delimiter syntax to use for un-escaping.

Example:

escapeDelims.unescape('(;^__^;) first (;\^_\^;)<%= last %>', ['<%%', '%>']);
//=> '<%= first %><%= last %>'

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert
Released under the MIT license


This file was generated by verb on November 11, 2014.

Current Tags

  • 0.4.0                                ...           latest (11 years ago)

5 Versions

  • 0.4.0                                ...           11 years ago
  • 0.3.0                                ...           12 years ago
  • 0.2.0                                ...           12 years ago
  • 0.1.1                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (2)

Copyright 2013 - present © cnpmjs.org | Home |