template/util/rst-mixin.js
function pre() {
  return function(data, render) {
    // remove first line if empty ; it happens because of
    // the {{pre}} tag on one line.
    logger.debug('empty line:', Boolean(data.match(/^\s+\n/, '')));
    data = data.replace(/^\s+\n/, '');
    // Find the first non-empty lines tabulation
    var m = data.match(/^([ \r\t]+)[^\s]/m);
    if (!m) {
      return render(data);
    }
    var prefix = m[1];
    // remove the prefix from the beginning of all lines before rendering
    data = data.replace(new RegExp('^' + prefix, 'mg'), '');
    var output = render(data);
    output = output.replace(/\n/mg, '\n' + prefix);
    // Depending what kind of content is on the first line, it might
    // or might not keep the spacing...
    // if the first does not contains the pattern, add it
    if (data.substring(0, prefix.length) !== prefix) {
      output = prefix + output;
    }
    return output;
  };
}
function pre() {
  return function(data, render) {
    // remove first line if empty ; it happens because of
    // the {{pre}} tag on one line.
    logger.debug('empty line:', Boolean(data.match(/^\s+\n/, '')));
    data = data.replace(/^\s+\n/, '');
    // Find the first non-empty lines tabulation
    var m = data.match(/^([ \r\t]+)[^\s]/m);
    if (!m) {
      return render(data);
    }
    var prefix = m[1];
    // remove the prefix from the beginning of all lines before rendering
    data = data.replace(new RegExp('^' + prefix, 'mg'), '');
    var output = render(data);
    output = output.replace(/\n/mg, '\n' + prefix);
    // Depending what kind of content is on the first line, it might
    // or might not keep the spacing...
    // if the first does not contains the pattern, add it
    if (data.substring(0, prefix.length) !== prefix) {
      output = prefix + output;
    }
    return output;
  };
}
function pre ( ) { return function ( data , render ) { // remove first line if empty ; it happens because of // the {{pre}} tag on one line. logger . debug ( 'empty line:' , Boolean ( data . match ( / ^\s+\n / , '' ) ) ) ; data = data . replace ( / ^\s+\n / , '' ) ; // Find the first non-empty lines tabulation var m = data . match ( / ^([ \r\t]+)[^\s] / m ) ; if ( ! m ) { return render ( data ) ; } var prefix = m [ 1 ] ; // remove the prefix from the beginning of all lines before rendering data = data . replace ( new RegExp ( '^' + prefix , 'mg' ) , '' ) ; var output = render ( data ) ; output = output . replace ( / \n / mg , '\n' + prefix ) ; // Depending what kind of content is on the first line, it might // or might not keep the spacing... // if the first does not contains the pattern, add it if ( data . substring ( 0 , prefix . length ) !== prefix ) { output = prefix + output ; } return output ; } ; }
Mustache lambda to preserve whitespace of the given string.

@return {function} Mustache lambda
Mustache lambda to preserve whitespace of the given string .