{"name":"uri-templates","version":"0.2.0","description":"URI Templates (RFC6570) including de-substitution","main":"uri-templates.js","scripts":{"test":"mocha --bail"},"repository":{"type":"git","url":"https://github.com/geraintluff/uri-templates.git"},"keywords":["rfc6570","uri","template"],"author":{"name":"Geraint Luff"},"license":"http://geraintluff.github.io/tv4/LICENSE.txt","gitHead":"3c65c2e1809e8c0dca1fb6b440c18fbc7acd85da","devDependencies":{"grunt":"~0.4.1","grunt-contrib-clean":"~0.4.1","grunt-contrib-jshint":"~0.6.0","mocha":"~1.11.0","grunt-mocha":"~0.3.4","grunt-mocha-test":"~0.5.0","grunt-cli":"~0.1.9","grunt-contrib-uglify":"~0.2.2","grunt-contrib-copy":"~0.4.1","proclaim":"1.4","mocha-unfunk-reporter":"~0.2","jshint-path-reporter":"~0.1","grunt-concat-sourcemap":"~0.2","source-map-support":"~0.1","grunt-markdown":"~0.3.0"},"bugs":{"url":"https://github.com/geraintluff/uri-templates/issues"},"_id":"uri-templates@0.2.0","_shasum":"2b5784511cc909868731e9233c268097d10b499f","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.5.0","_npmUser":{"name":"geraintluff","email":"luffgd@gmail.com"},"dist":{"shasum":"2b5784511cc909868731e9233c268097d10b499f","tarball":"http://registry-npm.ywwl.com/uri-templates/download/uri-templates-0.2.0.tgz","integrity":"sha512-EWkjYEN0L6KOfEoOH6Wj4ghQqU7eBZMJqRHQnxQAq+dSEzRPClkWjf8557HkWQXF6BrAUoLSAyy9i3RVTliaNg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC7hpAzxN8Edh3hD3ERttAf/LxRikQZnt7NpRItjU90YAiA/aDRG5oAgmvw99Z5ZUOQvjinJ/XXwyK6Vrt45z5J2Zw=="}],"size":43773,"noattachment":false,"key":"/uri-templates/-/uri-templates-0.2.0.tgz"},"maintainers":[{"name":"geraintluff","email":"luffgd@gmail.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/uri-templates-0.2.0.tgz_1464537977963_0.9199858594220132"},"directories":{},"readme":"# uri-templates\n\nURI Templates ([RFC6570](http://tools.ietf.org/html/rfc6570)) in JavaScript, including de-substitution.\n\nIt is tested against the [official test suite](https://github.com/uri-templates/uritemplate-test), including the extended tests.\n\nThe \"de-substitution\" extracts parameter values from URIs.  It is also tested against the official test suite (including extended tests).\n\n## Creation\n\nIn Node:\n```javascript\nvar uriTemplates = require('uri-templates');\nvar template1 = uriTemplates(\"/date/{colour}/{shape}/\");\n```\n\nIn browser:\n```javascript\nvar template2 = new UriTemplate(\"/prefix/{?params*}\");\n```\n\n## Substitution using an object\n```javascript\n// \"/categories/green/round/\"\nvar uri1 = template1.fill({colour: \"green\", shape: \"round\"});\n\n// \"/prefix/?a=A&b=B&c=C\nvar uri2 = template2.fillFromObject({\n\tparams: {a: \"A\", b: \"B\", c: \"C\"}\n});\n```\n\n## Substitution using a callback\n```javascript\n// \"/categories/example_colour/example_shape/\"\nvar uri1b = template1.fill(function (varName) {\n\treturn \"example_\" + varName;\n});\n```\n\n## Guess variables from URI (\"de-substitution\")\n\n```javascript\nvar uri2b = \"/prefix/?beep=boop&bleep=bloop\";\nvar params = template2.fromUri(url2b);\n/*\n\t{\n\t\tparams: {\n\t\t\tbeep: \"boop\",\n\t\t\tbleep: \"bloop\"\n\t\t}\n\t}\n*/\n```\n\nWhile templates can be ambiguous (e.g. `\"{var1}{var2}\"`), it will still produce *something* that reconstructs into the original URI.\n\nIt can handle all the cases in the official test suite, including the extended tests:\n\n```javascript\nvar template = uriTemplate(\"{/id*}{?fields,token}\");\n\nvar values = template.fromUri(\"/person/albums?fields=id,name,picture&token=12345\");\n/*\n{\n\tid: [\"person\", 'albums\"],\n\tfields: [\"id\", \"name\", \"picture\"],\n\ttoken: \"12345\"\n}\n*/\n```\n\n### `strict` option\n\nSometimes, you might want a more exact match, instead of a best guess.  For example, this could be useful when using URI Templates for routing.\n\nThe `strict` option performs more checks, to see whether the URI being matched is plausible:\n\n```javascript\nvar template = uriTemplate(\"/prefix/{value}/{suffix}\");\n\n// Matches, even though \"foo/bar\" contains a \"/\" which is not allowed\nvar looseMatch = template.fromUri('/prefix/foo/bar/suffix');\n// Does not match\nvar strictMatch = template.fromUri('/prefix/foo/bar/suffix', {strict: true});\n\n```\n\n## Test URI\n\n```javascript\nvar uri2b = \"/prefix/?beep=boop&bleep=bloop\";\nvar isMatch = template2.test(url2b); // === true\n```\n\nThis returns a boolean, and takes the same options as `.fromUri()`.\n\n## License\n\nThis project is released as [public-domain](http://geraintluff.github.io/tv4/LICENSE.txt).  Anybody can modify or re-license it for any purpose, without restriction.\n","publish_time":1464537979965,"_cnpm_publish_time":1464537979965,"dist-tags":{"latest":"0.2.0"}}