Sha256: 98d3a3bf7749af445ac928519bd8e90ee61208af699caab745c26863890f163a

Contents?: true

Size: 925 Bytes

Versions: 42

Compression:

Stored size: 925 Bytes

Contents

/*!
 * Jade - utils
 * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
 * MIT Licensed
 */

/**
 * Convert interpolation in the given string to JavaScript.
 *
 * @param {String} str
 * @return {String}
 * @api private
 */

var interpolate = exports.interpolate = function(str){
  return str.replace(/(\\)?([#!]){(.*?)}/g, function(str, escape, flag, code){
    return escape
      ? str
      : "' + "
        + ('!' == flag ? '' : 'escape')
        + "((interp = " + code.replace(/\\'/g, "'")
        + ") == null ? '' : interp) + '";
  });
};

/**
 * Escape single quotes in `str`.
 *
 * @param {String} str
 * @return {String}
 * @api private
 */

var escape = exports.escape = function(str) {
  return str.replace(/'/g, "\\'");
};

/**
 * Interpolate, and escape the given `str`.
 *
 * @param {String} str
 * @return {String}
 * @api private
 */

exports.text = function(str){
  return interpolate(escape(str));
};

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
stylus-source-0.49.3 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.42.2 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.42.1 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.42.0 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.41.3 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.41.2 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.41.1 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.41.0 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.40.3 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.40.2 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.40.1 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.40.0 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.39.4 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.39.3 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.39.2 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.39.1 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.39.0 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.38.0 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.37.0 vendor/node_modules/mocha/node_modules/jade/lib/utils.js
stylus-source-0.36.1 vendor/node_modules/mocha/node_modules/jade/lib/utils.js