Sha256: 3db0884246a61ba0920dcb6b50f1004bf79bc31658d90e4d568ebb2ed7f8370e

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

const { concat, hardline, join, markAsRoot } = require("../prettier");

const comment = require("./nodes/comment");
const doctype = require("./nodes/doctype");
const filter = require("./nodes/filter");
const hamlComment = require("./nodes/hamlComment");
const script = require("./nodes/script");
const silentScript = require("./nodes/silentScript");
const tag = require("./nodes/tag");

const nodes = {
  comment,
  doctype,
  filter,
  haml_comment: hamlComment,
  plain: (path, _opts, _print) => {
    const { value } = path.getValue();

    return value.text.startsWith("=") ? `\\${value.text}` : value.text;
  },
  root: (path, opts, print) =>
    markAsRoot(concat([join(hardline, path.map(print, "children")), hardline])),
  script,
  silent_script: silentScript,
  tag
};

const genericPrint = (path, opts, print) => {
  const { type } = path.getValue();

  if (!(type in nodes)) {
    throw new Error(`Unsupported node encountered: ${type}`);
  }

  return nodes[type](path, opts, print);
};

module.exports = genericPrint;

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
prettier-0.20.0 src/haml/print.js
prettier-0.19.1 src/haml/print.js
prettier-0.19.0 src/haml/print.js
prettier-0.18.2 src/haml/print.js
prettier-0.18.1 src/haml/print.js
prettier-0.18.0 src/haml/print.js
prettier-0.17.0 src/haml/print.js
prettier-0.16.0 src/haml/print.js