{"_id":"@allmarkedup/nunjucks-with","_rev":"3-7983b0e905a5108ff8693c885811bc19","name":"@allmarkedup/nunjucks-with","description":"A scoped context block extension for Nunjucks","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.0":{"name":"@allmarkedup/nunjucks-with","version":"0.1.0","description":"A scoped context block extension for Nunjucks","homepage":"http://fractal.build","repository":{"type":"git","url":"https://github.com/frctl/fractal/tree/v2/packages/internals/support"},"bugs":{"url":"https://github.com/frctl/fractal/issues"},"author":{"name":"Mark Perkins","email":"mark@allmarkedup.com","url":"http://allmarkedup.com"},"license":"MIT","dependencies":{"nunjucks":"^3.0.1"},"gitHead":"b1faaebf351f528b0490857143863294137022bb","_id":"@allmarkedup/nunjucks-with@0.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.3.0","_npmUser":{"name":"allmarkedup","email":"mark@allmarkedup.com"},"dist":{"integrity":"sha512-PIPdyAKKMkgd6ctysvGNQcp7NOUmQub2aUXWrX47LZnyPMhKu7fzFYssW+v2u7X9mGuWp3IBGCQ/uytSCfNoRA==","shasum":"a013f6a73dd92daf1d56f6eee8c852f78378039d","tarball":"https://registry.npmjs.org/@allmarkedup/nunjucks-with/-/nunjucks-with-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBC/SG5DfJkKkM5u6ap1RCuawmxHd9zVgb1nfHXLgCWbAiANwwHvlvFHWrrpYVBZuqVEThS/OGhO8+63QGPSPKUE7g=="}]},"maintainers":[{"name":"allmarkedup","email":"mark@allmarkedup.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nunjucks-with-0.1.0.tgz_1508789485564_0.903868036577478"}},"0.1.1":{"name":"@allmarkedup/nunjucks-with","version":"0.1.1","description":"A scoped context block extension for Nunjucks","homepage":"https://github.com/allmarkedup/nunjucks-with","repository":{"type":"git","url":"git+https://github.com/allmarkedup/nunjucks-with.git"},"bugs":{"url":"https://github.com/allmarkedup/nunjucks-with/issues"},"author":{"name":"Mark Perkins","email":"mark@allmarkedup.com","url":"http://allmarkedup.com"},"keywords":["nunjucks","context","scope"],"license":"MIT","dependencies":{"nunjucks":"^3.0.1"},"gitHead":"2c7c3ccca22ba17ac4b66256105e56918ee215cf","_id":"@allmarkedup/nunjucks-with@0.1.1","_npmVersion":"5.3.0","_nodeVersion":"8.3.0","_npmUser":{"name":"allmarkedup","email":"mark@allmarkedup.com"},"dist":{"integrity":"sha512-Jbxt3G+krSLjf41OZqXXXqNUcMNlEf9YGBp/DTWaniWegFYPAdbLppAeCIqyJU7nadPMrXT1jK/I4Rz7R9RkAg==","shasum":"f4afa2828edc15ca2e6e61877ee02d2a227cee33","tarball":"https://registry.npmjs.org/@allmarkedup/nunjucks-with/-/nunjucks-with-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFVeYm3sfv9SXnM4qVpH/b1Z6L0Y+D9tQxK3rNGmebrcAiBZQZ6SzwZ1QVCuELnyR4SEIckaEwNpf1UTpvgdbtIICQ=="}]},"maintainers":[{"name":"allmarkedup","email":"mark@allmarkedup.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nunjucks-with-0.1.1.tgz_1508789694075_0.8220011035446078"}},"0.1.2":{"name":"@allmarkedup/nunjucks-with","version":"0.1.2","description":"A scoped context block extension for Nunjucks","homepage":"https://github.com/allmarkedup/nunjucks-with","repository":{"type":"git","url":"git+https://github.com/allmarkedup/nunjucks-with.git"},"bugs":{"url":"https://github.com/allmarkedup/nunjucks-with/issues"},"author":{"name":"Mark Perkins","email":"mark@allmarkedup.com","url":"http://allmarkedup.com"},"keywords":["nunjucks","context","scope"],"license":"MIT","dependencies":{"chai":"^4.1.2","nunjucks":"^3.0.1"},"devDependencies":{"mocha":"^3.2.0"},"scripts":{"test":"mocha"},"gitHead":"04169977ea70f4c72b23ac2c1820c85b88deb0bc","_id":"@allmarkedup/nunjucks-with@0.1.2","_npmVersion":"5.3.0","_nodeVersion":"8.3.0","_npmUser":{"name":"allmarkedup","email":"mark@allmarkedup.com"},"dist":{"integrity":"sha512-2QYGOBIxWg+wxe9Itaxrn9iE+4li043b54mb5ac9G3pVRyM7b2MkKE2Ol+Xrz+9ssXPiQ5WGn3XMfsREszwpAg==","shasum":"dc4e1f5b913f88cbb0419b17f4f6b5ab6b6737e5","tarball":"https://registry.npmjs.org/@allmarkedup/nunjucks-with/-/nunjucks-with-0.1.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFAq92way+MkqT31vxrsOIbI6d7WZB0hKxudRg1Fpy/9AiEA35XTppGiBVm8QZhmjQT1ouUy8NYbppQcNtyXCNB8fzY="}]},"maintainers":[{"name":"allmarkedup","email":"mark@allmarkedup.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nunjucks-with-0.1.2.tgz_1508795267353_0.716338201193139"}}},"readme":"# Nunjucks 'with'\n\nA scoped context block extension for Nunjucks.\n\n## Installation\n\n```\nnpm i @allmarkedup/nunjucks-with\n```\n\n## Usage\n\n`nunjucks-with` works similarly to the `with` statement in JavaScript\n\n```js\nconst nunjucks = require('nunjucks');\nconst WithExtension = require('@allmarkedup/nunjucks-with');\nconst env = new nunjucks.Environment(/* loaders etc... */);\n\nenv.addExtension('WithExtension', new WithExtension());\n\nconst tpl = `\n{{ level }}\n{% with nested %}\n{{ level }}\n{% endwith %}\n`;\n\nconst output = env.renderString(tpl, {\n  level: 'one',\n  nested: {\n    level: 'two'\n  }\n});\n\nconsole.log(output);\n/* \none\ntwo\n*/\n\n```\n\nYou can also pass in objects defined on the fly:\n\n```nunjucks\n{% set myScope = 'global' %}\n{{ scope }} <!-- outputs 'global' -->\n\n{% with {myScope: 'block'} %}\n{{ myScope }} <!-- outputs 'block' -->\n{% endwith %}\n```\n\nNunjucks doesn't let you pass in scope when `include`-ing templates, so `nunjucks-with` is pretty handy for isolating scope for your includes to avoid variable name clashes:\n\n```nunjucks\n<!-- views/main.tpl -->\n<p>{{ text }}<p>\n{% with button %}{% include 'button.tpl' %}{% endwith %}\n\n<!-- views/button.tpl -->\n<button>{{ text }}</button>\n```\n\n```js\nconst output = env.render('main.tpl', {\n  text: 'you should to this',\n  button: {\n    text: 'click here'\n  }\n});\n\n/*\n<p>you should to this</p>\n<button>click here</button>\n */\n```\n\n## Credits:\n\n`nunjucks-with` is based on code by @vinnyrose in a comment on the Nujucks issue tracker: https://github.com/mozilla/nunjucks/issues/722#issuecomment-281722126\n\n\n\n","maintainers":[{"name":"allmarkedup","email":"mark@allmarkedup.com"}],"time":{"modified":"2022-04-04T13:33:24.874Z","created":"2017-10-23T20:11:26.471Z","0.1.0":"2017-10-23T20:11:26.471Z","0.1.1":"2017-10-23T20:14:54.890Z","0.1.2":"2017-10-23T21:47:48.527Z"},"homepage":"https://github.com/allmarkedup/nunjucks-with","repository":{"type":"git","url":"git+https://github.com/allmarkedup/nunjucks-with.git"},"author":{"name":"Mark Perkins","email":"mark@allmarkedup.com","url":"http://allmarkedup.com"},"bugs":{"url":"https://github.com/allmarkedup/nunjucks-with/issues"},"license":"MIT","readmeFilename":"README.md","keywords":["nunjucks","context","scope"]}