{"name":"pug-attrs","version":"2.0.4","description":"Generate code for Pug attributes","keywords":["pug"],"dependencies":{"constantinople":"^3.0.1","js-stringify":"^1.0.1","pug-runtime":"^2.0.5"},"repository":{"type":"git","url":"https://github.com/pugjs/pug/tree/master/packages/pug-attrs"},"author":{"name":"Forbes Lindesay"},"license":"MIT","gitHead":"1bdf628a70fda7a0d840c52f3abce54b1c6b0130","_id":"pug-attrs@2.0.4","_nodeVersion":"11.14.0","_npmVersion":"lerna/3.10.8/node@v11.14.0+x64 (darwin)","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"dist":{"integrity":"sha512-TaZ4Z2TWUPDJcV3wjU3RtUXMrd3kM4Wzjbe3EWnSsZPsJ3LDI0F3yCnf2/W7PPFF+edUFQ0HgDL1IoxSz5K8EQ==","shasum":"b2f44c439e4eb4ad5d4ef25cac20d18ad28cc336","tarball":"http://registry-npm.ywwl.com/pug-attrs/download/pug-attrs-2.0.4.tgz","fileCount":4,"unpackedSize":7702,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdCLKdCRA9TVsSAnZWagAAKh4P/0W8EzSZj6FA4gRqqQhF\n5eXzg011WcKOvyXisJAszQowcCa887+oCVKFSdx2E7oW+YNCn0qRdqEjykvB\nqmwC2l0yuayNk8NY9PGckhsuvvzxuHRzvqEF6Fn5EzuG4HHDAo+OzuJGWqUV\nfAqv8JBumyyLgkOQ+eCNNRK0qzewRy8cdUUb0mXEXaPIZAnwGz9NWcOfC7XK\nIzxlX6xFJtreXKPY6e+NG+ZOuIsakVB8WAaukHLQnbF1ecTrEByozJ0rVgO0\nnoN+212+ezO6JCxxa7yy/gBFWCggSfAHY6Ua4sV6vlPVSIyRBHflZh7LSKSg\njUQ36r2YTTQnm7xoUWp7O2ZbFq7hSGIxIpql1dWmbB5+rzNAd1YU+fGVLLKK\nW1bSTATsKMZnsw9ooWLDVyzkQznt773ygLLm25Nv+bH7KnB4dlKLb3NBNlqx\nAAtoj2gkBqTygH+ZC42Q1uY/9TBem1Wrn17zQ9BcDULwjvRIfAAm4XyfVKLE\nZae9HxhcYVyZxFQ6+AoUv1w497iavVX++33GRdDLeLoaMEkNoY6lZQjy/Quu\nHXjRYYY54EiDo3J9tRxoXdz/OaCjA8XFPQa8+cC8z7lawzdq7x1eon2t8KbN\nK1A3HFNyE09sz/h86O8VmL7ow8e5kg5jwbEDFiOb6Vak37Nl9Ppo13LCAaDB\n819U\r\n=H92a\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE8jRxgRM+3DjlFD1c5ljt/eTXhVoatU3yYOcqPEzd1wAiBHTMBaG8kgTbQv7W2hToj1lmCqjJ9kmUeatmgn3QG5sg=="}],"size":3008,"noattachment":false,"key":"/pug-attrs/-/pug-attrs-2.0.4.tgz"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},{"name":"timothygu","email":"timothygu99@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pug-attrs_2.0.4_1560851100790_0.9701860599370475"},"_hasShrinkwrap":false,"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":1560851100908,"_cnpm_publish_time":1560851100908,"dist-tags":{"canary":"3.0.0-canary-2","latest":"3.0.0"}}