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

escape-delims

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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.

  • 0.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6K
increased by438.57%
Maintainers
1
Weekly downloads
 
Created
Source

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.

Keywords

FAQs

Package last updated on 11 Nov 2014

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