@rawwee/prettier-plugin-twig-melody
Version:
Prettier Plugin for Twig/Melody (Enhanced Fork)
24 lines (19 loc) • 576 B
JavaScript
const prettier = require("prettier");
const { concat, join, indent, hardline } = prettier.doc.builders;
const {
createTextGroups,
stripHtmlCommentChars,
normalizeHtmlComment,
countNewlines
} = require("../util");
const p = (node, path, print) => {
const commentText = stripHtmlCommentChars(node.value.value || "");
const numNewlines = countNewlines(commentText);
if (numNewlines === 0) {
return normalizeHtmlComment(commentText);
}
return concat(["<!-- ", commentText, " -->"]);
};
module.exports = {
printHtmlComment: p
};