{"name":"pug-attrs","version":"2.0.2","description":"Generate code for Pug attributes","keywords":["pug"],"dependencies":{"constantinople":"^3.0.1","pug-runtime":"^2.0.3","js-stringify":"^1.0.1"},"repository":{"type":"git","url":"git+https://github.com/pugjs/pug-attrs.git"},"author":{"name":"Forbes Lindesay"},"license":"MIT","bugs":{"url":"https://github.com/pugjs/pug-attrs/issues"},"homepage":"https://github.com/pugjs/pug-attrs#readme","_id":"pug-attrs@2.0.2","scripts":{},"_shasum":"8be2b2225568ffa75d1b866982bff9f4111affcb","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.4.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},{"name":"timothygu","email":"timothygu99@gmail.com"}],"dist":{"shasum":"8be2b2225568ffa75d1b866982bff9f4111affcb","tarball":"http://registry-npm.ywwl.com/pug-attrs/download/pug-attrs-2.0.2.tgz","integrity":"sha512-3Hrz8Os5Rv1QdWLygyChY+Xfz3ZrNkBN+E+WIaikZQIy4BJ4tL4GjTzbx1mZCEDrn8PYIPJuxQiJkqRtR/vSUA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGDG5Odef9ExmwTsFRBKi/m/b0PK0UyH9xXfE/7pUILLAiAfN1HUE9VXAHodnCIKmY8P479hamLDu03yzl65pDVgdg=="}],"size":3807,"noattachment":false,"key":"/pug-attrs/-/pug-attrs-2.0.2.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/pug-attrs-2.0.2.tgz_1485220030858_0.5362752785440534"},"directories":{},"readme":"# pug-attrs\n\nGenerate code for Pug attributes\n\n[![Build Status](https://img.shields.io/travis/pugjs/pug-attrs/master.svg)](https://travis-ci.org/pugjs/pug-attrs)\n[![Dependencies Status](https://david-dm.org/pugjs/pug/status.svg?path=packages/pug-attrs)](https://david-dm.org/pugjs/pug?path=packages/pug-attrs)\n[![NPM version](https://img.shields.io/npm/v/pug-attrs.svg)](https://www.npmjs.org/package/pug-attrs)\n\n## Installation\n\n    npm install pug-attrs\n\n## Usage\n\n```js\nvar compileAttrs = require('pug-attrs');\n```\n\n### `compileAttrs(attrs, options)`\n\nCompile `attrs` to a JavaScript string that evaluates to the attributes in the desired format.\n\n`options` MUST include the following properties:\n\n- `terse`: whether or not to use HTML5-style terse boolean attributes\n- `runtime`: callback that takes a runtime function name and returns the source code that will evaluate to that function at runtime\n- `format`: output format; must be `html` or `object`\n\n`attrs` is an array of attributes, with each attribute having the form of `{ name, val, mustEscape }`. `val` represents a JavaScript string that evaluates to the value of the attribute, either statically or dynamically.\n\n```js\nvar compileAttrs = require('pug-attrs');\nvar pugRuntime = require('pug-runtime');\n\nfunction getBaz () { return 'baz<>'; }\n\nvar attrs = [\n  {name: 'foo',  val: '\"bar\"',    mustEscape: true },\n  {name: 'baz',  val: 'getBaz()', mustEscape: true },\n  {name: 'quux', val: true,       mustEscape: false}\n];\nvar result, finalResult;\n\n// HTML MODE\nresult = compileAttrs(attrs, {\n  terse:   true,\n  format:  'html',\n  runtime: function (name) { return 'pugRuntime.' + name; }\n});\n//=> '\" foo=\\\\\"bar\\\\\"\" + pugRuntime.attr(\"baz\", getBaz(), true, true) + \" quux\"'\n\nfinalResult = Function('pugRuntime, getBaz',\n  'return (' + result + ');'\n);\nfinalResult(pugRuntime, getBaz);\n// => ' foo=\"bar\" baz=\"baz&lt;&gt;\" quux'\n\n// OBJECT MODE\nresult = compileAttrs(attrs, {\n  terse:   true,\n  format:  'object',\n  runtime: function (name) { return 'pugRuntime.' + name; }\n});\n//=> '{\"foo\": \"bar\",\"baz\": pugRuntime.escape(getBaz()),\"quux\": true}'\n\nfinalResult = Function('pugRuntime, getBaz',\n  'return (' + result + ');'\n);\nfinalResult(pugRuntime, getBaz);\n//=> { foo: 'bar', baz: 'baz&lt;&gt;', quux: true }\n```\n\n## License\n\n  MIT\n","publish_time":1485220032810,"_cnpm_publish_time":1485220032810,"dist-tags":{"canary":"3.0.0-canary-2","latest":"3.0.0"}}