{"name":"pug-attrs","version":"0.0.1","description":"Generate code for jade attributes","keywords":["jade"],"dependencies":{"constantinople":"^3.0.1","pug-runtime":"^0.0.0","js-stringify":"^1.0.1"},"devDependencies":{"istanbul":"*","testit":"^2.0.2"},"scripts":{"test":"node test","coverage":"istanbul cover test"},"repository":{"type":"git","url":"https://github.com/jadejs/jade-attrs.git"},"author":{"name":"Forbes Lindesay"},"license":"MIT","gitHead":"575ce538b73c6afa4d4641f158255a96c3e0fb1f","bugs":{"url":"https://github.com/jadejs/jade-attrs/issues"},"homepage":"https://github.com/jadejs/jade-attrs","_id":"pug-attrs@0.0.1","_shasum":"a50949e53935c153aec9748da092f9281dfc60cc","_from":".","_npmVersion":"2.7.1","_nodeVersion":"1.6.2","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"dist":{"shasum":"a50949e53935c153aec9748da092f9281dfc60cc","tarball":"http://registry-npm.ywwl.com/pug-attrs/download/pug-attrs-0.0.1.tgz","integrity":"sha512-e21taJGaFdZbYyOM3t3n1Dy4li/QnnfCxlPGMBJLSd1kPngOv0onEsxOOXd3mefVYt7H3nk5XGLxF07oiPYShw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIH6rscCUQnWk82oIvIwh2TGrxPeCtXIGX8ruXktnXyPPAiBDH2foW7W0WPi1y/uSPF2UFEGXuvgWNoqLz6Y+QcttJw=="}],"size":5230,"noattachment":false,"key":"/pug-attrs/-/pug-attrs-0.0.1.tgz"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"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":1449879381473,"_cnpm_publish_time":1449879381473,"dist-tags":{"canary":"3.0.0-canary-2","latest":"3.0.0"}}