marko-prettyprint v2.0.0
marko-prettyprint
Prettyprint Marko template files in the syntax and with the options of your choice.
Installation
Global install of the command line utility:
npm install marko-prettyprint --globalLocal project install:
npm install marko-prettyprint --saveUsage
Pretty print a single file from the command line
marko-prettyprint template.marko --syntax htmlPretty print a directory tree from the command line
marko-prettyprint . --syntax htmlPretty print a file in a Node.js app
var prettyPrintFile = require('marko-prettyprint').prettyPrintFile;
var templatePath = require('path').join(__dirname, 'template.marko');
var options = {
syntax: 'html'
};
var prettySrc = prettyPrintFile(templatePath, options);Options
eol- The EOL sequence (defaults torequire('os').EOL)filename- The path to the template being pretty printed (required unlessprettyPrintFile(filename, options)is used)indent- The indent string (defaults to aStringwith four spaces)noSemi- If set, will format JS without semicolons.singleQuote- If set, will prefer single quotes.maxLen- The max line length (defaults to80, set to-1to disable)configFiles- Should search for.marko-prettyprint/.editorconfigfiles? (defaults totrue)syntax- The syntax to use. Can either be"html"or"concise"(defaults to"html")
Configuration files
.marko-prettyprint config file
When pretty printing a Marko template, marko-prettyprint will search up the directory tree looking for a .marko-prettyprint file. This file should be in the JSON format. For example:
my-project/.marko-prettyprint:
{
"indent": "\t",
"syntax": "concise"
}.editorconfig file
marko-prettyprint also supports EditorConfig files for configuring maxLen, indent and eol. For example:
my-project/.editorconfig:
root = true
[*.marko]
indent_style = space
indent_size = 8
end_of_line = lfAPI
JavaScript API
require('marko-prettyprint')
prettyPrintSource(src, options)
prettyPrintFile(filename, options)
prettyPrintAST(ast, options)
Command Line
To recursively prettyprint all Marko v3 templates in a directory to use the HTML syntax:
marko-prettyprint . --syntax htmlTo recursively prettyprint all Marko v3 templates in a directory to use the HTML syntax:
marko-prettyprint . --syntax conciseIndividual files and directories can also be prettyprinted:
marko-prettyprint src/ foo/
marko-prettyprint template1.marko template2.markoThe maximum line length (defaults to 80) can be also be set:
marko-prettyprint . --syntax html --max-len 1207 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago