How to use the stylus/lib/utils.merge function in stylus

To help you get started, we’ve selected a few stylus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shama / stylus-loader / lib / evaluator.js View on Github external
// Parse the file
  importStack.push(file);
  nodes.filename = file;

  var str;
  if (this.cache.sources && this.cache.sources[file]) {
    str = this.cache.sources[file];
  } else {
    str = fs.readFileSync(file, 'utf8');
  }

  if (literal && !this.resolveURL) return new nodes.Literal(str.replace(/\r\n?/g, '\n'));

  // parse
  var block = new nodes.Block
    , parser = new Parser(str, utils.merge({ root: block }, this.options));

  try {
    block = parser.parse();
  } catch (err) {
    err.filename = file;
    err.lineno = parser.lexer.lineno;
    err.input = str;
    throw err;
  }

  // Evaluate imported "root"
  block.parent = this.root;
  block.scope = false;
  var ret = this.visit(block);
  importStack.pop();
  if (importStack.length || index) this.paths.pop();
github mockingbot / ibot / scripts / stylus-enhanced-evaluator.js View on Github external
if (file === importStack[importStack.length - 1]) return nodes.null

  if (this.options._imports) this.options._imports.push(node.clone())

  // Parse the file
  importStack.push(file)
  nodes.filename = file

  var str = fs.readFileSync(file, "utf8")

  if (literal && !this.resolveURL)
    return new nodes.Literal(str.replace(/\r\n?/g, "\n"))

  // parse
  var block = new nodes.Block(),
    parser = new Parser(str, utils.merge({ root: block }, this.options))

  try {
    block = parser.parse()
  } catch (err) {
    err.filename = file
    err.lineno = parser.lexer.lineno
    err.input = str
    throw err
  }

  // Evaluate imported "root"
  block.parent = this.root
  block.scope = false
  var ret = this.visit(block)
  importStack.pop()
  if (importStack.length || index) this.paths.pop()