{"bugs":{"url":"https://github.com/helpers/prettify/issues"},"dist":{"shasum":"e1d1e4a1a0a42f476d72a0c5b18580801fe29643","tarball":"https://registry.npmjs.org/prettify/-/prettify-0.1.7.tgz","integrity":"sha512-QqshRIzghly4SYi7U6eaCbwT9wkRQ4vPAziGlNgnYKOn/pgxrP+yigOrvvBknpgX+xD4Mhh8h2h+BpF2ptU+SA==","signatures":[{"sig":"MEYCIQCWr2UGhZEOyeeG3bSfL1+xkqR9a5NsTpymFKogsOF0iQIhAPU8uADZKXtNYJ+4kTh7vmevTp19B9MQ3O1vnJHri4+S","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"prettify.js","name":"prettify","_from":".","author":{"url":"https://github.com/jonschlinkert","name":"Jon Schlinkert"},"readme":"# {{prettify}} [![NPM version](https://badge.fury.io/js/prettify.png)](http://badge.fury.io/js/prettify) \r\n\r\n> {{prettify}} handlebars helper for formatting (beautifying) HTML, JavaScript and CSS.\r\n\r\nThis helper depends on and extends [js-beautify](https://github.com/einars/js-beautify). Please visit and star that project to show your support.\r\n\r\n[Also see examples →](./EXAMPLES.md)\r\n\r\n## Getting Started\r\nIn the root of the project in which you plan to use the helper, in the command line run:\r\n\r\n```bash\r\nnpm i prettify --save\r\n```\r\n\r\nUse within your application with the following line of JavaScript:\r\n\r\n```js\r\nvar helpers = require('prettify');\r\n```\r\n\r\nNow your handlebars instance will have access to the {{prettify}} helper.\r\n\r\n\r\n\r\n\r\n## Options\r\n### setting options\r\n\r\nAll options from [js-beautify](https://github.com/einars/js-beautify) are available in this helper, as well as a few custom options that were specially created for this helper. The helper comes with some sensible defaults (in the humble opinion of the helper creator), but it's easy to customize them if you need to. Here are are two (convenient) ways to set options:\r\n\r\n* **options hash**: this is an easy way to set options on the helper, and it gives you the most granular control over how the helper renders content.\r\n* **Assemble task options**: if you use both [Grunt](http://gruntjs.com/) and [Assemble](http://assemble.io), you can define options in your project's Gruntfile.\r\n\r\n\r\n#### options hash\r\nBy design, options define here will override options defined anywhere else.\r\n\r\n```handlebars\r\n{{#prettify indent=4}}\r\n  {{> body }}\r\n{{/prettify}}\r\n```\r\n\r\n\r\n#### \"assemble\" task options\r\nThe helper can be used without [Grunt](http://gruntjs.com/) or [Assemble](http://assemble.io). But if you happen to use these two awesome tools you can define options for the helper in your Gruntfile in the `prettify` sub-options for Assemble:\r\n\r\n```javascript\r\ngrunt.initConfig({\r\n  assemble: {\r\n    options: {\r\n      prettify: {\r\n        condense: true,\r\n        padcomments: true,\r\n        indent: 4\r\n      }\r\n    },\r\n    ...\r\n  }\r\n});\r\n```\r\n\r\nOptions defined in the Assemble task can be viewed as custom \"global\" defaults, which can be overridden by options defined in the options hash.\r\n\r\n\r\n### custom options\r\n\r\nIn addition to the options available from [js-beautify](https://github.com/einars/js-beautify), the following are custom options created specially for this helper.\r\n\r\n#### mode\r\nType: `String`\r\nDefault value: `html` (other options: `js`|`css`)\r\n\r\nIf you are formatting HTML, this does not need to be defined, but if you wish to format CSS or JavaScript you must specify either `js` or `css` respectively.\r\n\r\n```js\r\n{{#prettify mode=\"js\" indent=4}}\r\nfunction foo(str) {return str;}\r\n{{/prettify}}\r\n```\r\n\r\nNote that when you change the mode, the available _and allowed_ options change as well. If you specify an option for the wrong mode, the helper may or may not throw an error, so be cautious. This can be a bit tricky if you're building a project that is using the {{prettify}} helper in several places with different modes. It's easy to forget that you have a layout wrapped like this:\r\n\r\n```handlebars\r\n{{#prettify indent=2}}\r\n  {{> body }}\r\n{{/prettify}}\r\n```\r\nand then do this on one of the pages that uses that layout:\r\n\r\n```js\r\n{{#prettify mode=\"js\" indent=4}}\r\nfunction foo(str) {return str;}\r\n{{/prettify}}\r\n```\r\n\r\nThis won't throw an error, but the JavaScript inside the \"js\" block will be re-formatted by the outter instance of the helper. So based on this example the JavaScript in the \"js\" block will be indented to **2 spaces**.\r\n\r\n\r\n### option defaults\r\n\r\nHere are the available options and defaults for each mode.\r\n\r\n##### \"html\" mode\r\n\r\nThese options are available by default.\r\n\r\n```js\r\n{\r\n  \"indent_inner_html\": false,   // Indent <head> and <body> sections\r\n  \"indent_size\": 2,             // Indentation size\r\n  \"indent_char\": \" \",           // Indentation character. Can be an actual tab or space\r\n  \"brace_style\": \"expand\",      // collapse|expand|end-expand\r\n  \"indent-scripts\": \"normal\"    // keep|separate|normal\r\n  \"wrap_line_length\": 78,       // Maximum characters per line (0 disables this)\r\n  \"unformatted\": [\"a\", \"sub\", \"sup\", \"b\", \"i\", \"u\"], // List of tags that should not be reformatted (inline elements included by default)\r\n  \"preserve_newlines\": true,    // Preserve existing line-breaks\r\n  \"max_preserve_newlines\": 5,   // Maximum number of line-breaks to be preserved in one chunk\r\n\r\n  // custom options made for this helper\r\n  \"indent\": 2,          // convenience alias for indent_size\r\n  \"contense\": false,    // remove extra newlines missed by js-beautify.\r\n  \"padcomments\": false  // add an extra newline above each HTML code comment\r\n}\r\n```\r\n\r\n##### \"js\" mode\r\n\r\nWhen `mode` is set to `js`, the following options are available:\r\n\r\n```js\r\n{\r\n  \"indent_size\": 2,\r\n  \"indent_char\": \" \",\r\n  \"indent_level\": 0,\r\n  \"indent_with_tabs\": false,\r\n  \"preserve_newlines\": true,\r\n  \"max_preserve_newlines\": 10,\r\n  \"jslint_happy\": false,\r\n  \"brace_style\": \"collapse\",\r\n  \"keep_array_indentation\": false,\r\n  \"keep_function_indentation\": false,\r\n  \"space_before_conditional\": true,\r\n  \"break_chained_methods\": false,\r\n  \"eval_code\": false,\r\n  \"unescape_strings\": false,\r\n  \"wrap_line_length\": 0\r\n}\r\n```\r\n\r\n##### \"css\" mode\r\n\r\nWhen `mode` is set to `css`, the following options are available:\r\n\r\n```js\r\n{\r\n  \"indent_size\": 2,\r\n  \"indent_char\": \" \"\r\n}\r\n```\r\n\r\n\r\n#### indent\r\n_Alias for `indent_size`_.\r\nType: `Number`\r\nDefault value: `2`\r\n\r\nNumber of spaces or tabs to indent the generated code. This option is an _alias for `indent_size`_.\r\n\r\n#### condense\r\nType: `Boolean`\r\nDefault value: `true`\r\n\r\nRemoves extra newlines and retains indenting:\r\n\r\n#### padcomments\r\nType: `Boolean`\r\nDefault value: `True`\r\n\r\nAdd a newline above each code comment:\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n  <head>\r\n\r\n    <!-- code comment -->\r\n    <meta charset=\"UTF-8\">\r\n    <title>Document</title>\r\n  </head>\r\n  <body>\r\n    <h1>My Blog</h1>\r\n    <h2>Post of the day</h2>\r\n\r\n    <!-- scripts -->\r\n    <a href=\"#\">Read more...</a>\r\n  </body>\r\n</html>\r\n```\r\n\r\n\r\n\r\n\r\n\r\n\r\n## Usage Examples\r\n### Usage with Assemble\r\nUse this helper in a [\"parent\" layout](http://assemble.io/docs/Layouts.html):\r\n\r\n```handlebars\r\n{{#prettify}}\r\n  {{> body }}\r\n{{/prettify}}\r\n```\r\n_See [nested layouts](http://assemble.io/docs/Layouts.html#nested-layouts)_.\r\n\r\n### Indent Example\r\n\r\n#### Before\r\n\r\nUsing the `indent` option:\r\n\r\nTemplate: `index.hbs`\r\n\r\n```handlebars\r\n{{#prettify indent=\"2\"}}\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n<head>\r\n<meta charset=\"UTF-8\">\r\n<title>Document</title>\r\n</head>\r\n<body>\r\n<h1>My Blog</h1>\r\n<h2>Post of the day</h2>\r\n<p>\r\nVestibulum posuere, quam sed bibendum posuere\r\nPellentesque habitant morbi tristique senectus\r\nPellentesque nulla augue, volutpat vitae\r\n</p>\r\n<a href=\"#\">Read more...</a>\r\n</body>\r\n</html>\r\n{{/prettify}}\r\n```\r\n\r\n#### After\r\n\r\nRenders to:\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n  <head>\r\n    <meta charset=\"UTF-8\">\r\n    <title>Document</title>\r\n  </head>\r\n  <body>\r\n    <h1>My Blog</h1>\r\n    <h2>Post of the day</h2>\r\n    <p>\r\n      Vestibulum posuere, quam sed bibendum posuere\r\n      Pellentesque habitant morbi tristique senectus\r\n      Pellentesque nulla augue, volutpat vitae\r\n    </p>\r\n    <a href=\"#\">Read more...</a>\r\n  </body>\r\n</html>\r\n```\r\n\r\n\r\n### Condense Example\r\n\r\n#### Before\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n  <head>\r\n\r\n    <!-- code comment -->\r\n    <meta charset=\"UTF-8\">\r\n    <title>Document</title>\r\n\r\n\r\n  </head>\r\n\r\n\r\n  <body>\r\n    <h1>My Blog</h1>\r\n    <h2>Post of the day</h2>\r\n\r\n\r\n    <!-- scripts -->\r\n    <a href=\"#\">Read more...</a>\r\n\r\n\r\n  </body>\r\n</html>\r\n```\r\n\r\nExample output with `condensed: true`:\r\n\r\n### After\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n  <head>\r\n    <!-- code comment -->\r\n    <meta charset=\"UTF-8\">\r\n    <title>Document</title>\r\n  </head>\r\n  <body>\r\n    <h1>My Blog</h1>\r\n    <h2>Post of the day</h2>\r\n    <!-- scripts -->\r\n    <a href=\"#\">Read more...</a>\r\n  </body>\r\n</html>\r\n```\r\n\r\n#### Newlines\r\n\r\nWhen used with `condense`, defining `newlines: true` will result in something like this:\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html lang=\"en\">\r\n  <head>\r\n\r\n    <!-- code comment -->\r\n    <meta charset=\"UTF-8\">\r\n    <title>Document</title>\r\n  </head>\r\n  <body>\r\n    <h1>My Blog</h1>\r\n    <h2>Post of the day</h2>\r\n\r\n    <!-- scripts -->\r\n    <a href=\"#\">Read more...</a>\r\n  </body>\r\n</html>\r\n```\r\n\r\n\r\n\r\n## Contributing\r\nPlease see the [Contributing to Assemble](http://assemble.io/contributing) guide for information on contributing to this project.\r\n\r\n## Author\r\n\r\n+ [github.com/jonschlinkert](https://github.com/jonschlinkert)\r\n+ [twitter.com/jonschlinkert](http://twitter.com/jonschlinkert)\r\n\r\n\r\n## Related Projects and Links\r\n\r\n+ [handlebars-helpers](https://github.com/assemble/handlebars-helpers)\r\n+ [helpers](https://github.com/helpers): some great handlebars helpers that we decided not to include in the [handlebars-helpers](https://github.com/assemble/handlebars-helpers) project, most likely because the code footprint was too big or the helper wasn't generic enough.\r\n+ [grunt-prettify](https://github.com/jonschlinkert/grunt-prettify)\r\n\r\n## License\r\nCopyright (c) 2013 Jon Schlinkert, contributors.\r\nReleased under the MIT license\r\n\r\n***\r\n\r\n_This file was generated on Sat Sep 28 2013 11:48:36._\r\n","_npmUser":{"name":"jonschlinkert","email":"github@sellside.com"},"homepage":"https://github.com/helpers/prettify","keywords":["beautify","convenience methods","filter","format html","handlebars helper","helper","js-beautify","lodash","mixin","prettify","swig filter","template filter","underscore mixin","underscore"],"licenses":[{"url":"https://github.com/helpers/prettify/blob/master/LICENSE-MIT","type":"MIT"}],"repository":{"url":"https://github.com/helpers/prettify.git","type":"git"},"_npmVersion":"1.3.11","description":"{{prettify}} handlebars helper for formatting (beautifying) HTML, JavaScript and CSS.","directories":{},"maintainers":[{"name":"jonschlinkert","email":"github@sellside.com"}],"dependencies":{"lodash":"~1.3.1","js-prettify":"~1.4.0"},"readmeFilename":"README.md","devDependencies":{"grunt":"~0.4.1","assemble":"~0.4.7","js-prettify":"~1.4.0","grunt-readme":"~0.1.7","assemble-yaml":"~0.1.5","grunt-sync-pkg":"~0.1.0","grunt-mocha-test":"~0.7.0","grunt-contrib-clean":"~0.5.0","grunt-contrib-jshint":"~0.6.4","grunt-contrib-nodeunit":"~0.2.1"},"_id":"prettify@0.1.7","version":"0.1.7"}