{"_id":"@curiostack/nunjucks-extended","_rev":"1-68e2de896ed02f92965043cbb0794395","name":"@curiostack/nunjucks-extended","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@curiostack/nunjucks-extended","version":"1.0.0","description":"Curiostack extended version of nunjucks","repository":{"type":"git","url":"git+https://github.com/curioswitch/curiostack.git"},"author":{"name":"Walter Meiren","email":"walter@meiren.dev"},"license":"MIT","scripts":{"test":"jest","lint":"eslint . --ext .ts,.tsx --ignore-pattern *.d.ts --ignore-pattern **/src-template/**"},"dependencies":{"@types/nunjucks":"3.1.4","nunjucks":"3.2.2"},"devDependencies":{"@curiostack/base-node-dev":"0.2.0"},"jest":{"transform":{"^.+\\.ts?$":"ts-jest"}},"bugs":{"url":"https://github.com/curioswitch/curiostack/issues"},"homepage":"https://github.com/curioswitch/curiostack#readme","_id":"@curiostack/nunjucks-extended@1.0.0","_nodeVersion":"14.15.1","_npmVersion":"6.14.8","dist":{"integrity":"sha512-QnU+f8g6Xb90t9dwSA+Mcn2zzWmhD0xqrSHcsSFv/eV3YcK6TcaAC9+pIfpeS5tPSDuOMoPoaZSTbycB1NZorw==","shasum":"1558f1dc6b15b878dcae6d08a56037c2b1ad4567","tarball":"https://registry.npmjs.org/@curiostack/nunjucks-extended/-/nunjucks-extended-1.0.0.tgz","fileCount":13,"unpackedSize":19644,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgOeu3CRA9TVsSAnZWagAAveoQAJNrrTuv/CeHEHRMY0Aa\n1JD4QOgLkOVvkjEmQ3J2kE0Xd8Z0aAMuwx0CuWanwls+FpXl4i9LN1+hxLJb\nGE6HnUJ8uLYVSlTOPGThtJ897TqJqGOUjwdP/794GCXIeXv1L80HLgLSZ0Q1\npIEUjL17eUdDV4UaG5VC78NVJRU3XS/Gx4NQJmpQoTAdQuKrj//kfXRyopIE\nJqysuERtP1oiIAAgXm4YMLpfhq+3xLs32Zrwn/EB1zgSgz0Kr2i3LCPlWQhg\nCd+Z3z/+2wKqjRtcIE35Rqs/nRXVXoqn80pt/QzNa1BWJayC7euWGG1iHPE8\ndYLtPkjsbgLep3gCzP9bYmQVIvWXAWbEysA5WIgoYmZqs1cbFZ4WE5lQB3l6\najssGy+aBa6PeNZsyL5T2k8+AqVfhugAyvAR12wbRHWL0YK6JQcEK0w1f7Kk\nica4gRR7J96furuWw4sf/bOZTv3cx4skM7DRYpybeKpgjjJzYp+V00Dh3BgN\nm1BWhw7dg/e7JBkoIhHy1hd+y0j2fOcDOUn5nzDP/95a3YAzWj8hMWI+y2GB\n7vF8ybTGqRK9SCv0FOdtIhFRdb1uYb+Z3Sa8jbah3aqfc8w8HrjlbVrXTcgA\nHbWv5VAVjdBiuxnko+MAr63cwcTiJOTyUTZROIPzXquHZYct2njq/VXHYh8x\n7WeE\r\n=OcJZ\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCYVYWQ1yZtuyiJJGqHHXYA8YpNfOZEnuUVkyLhrqINAQIgBJ58VHDkqi+2bKGXtb43fCAWMvGGxQxZf7N2bx/olfA="}]},"_npmUser":{"name":"chokoswitch","email":"choko@curioswitch.org"},"directories":{},"maintainers":[{"name":"chokoswitch","email":"choko@curioswitch.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nunjucks-extended_1.0.0_1614408630780_0.7206211903436845"},"_hasShrinkwrap":false}},"time":{"created":"2021-02-27T06:50:30.635Z","1.0.0":"2021-02-27T06:50:30.944Z","modified":"2022-04-05T02:19:06.196Z"},"maintainers":[{"name":"chokoswitch","email":"choko@curioswitch.org"}],"description":"Curiostack extended version of nunjucks","homepage":"https://github.com/curioswitch/curiostack#readme","repository":{"type":"git","url":"git+https://github.com/curioswitch/curiostack.git"},"author":{"name":"Walter Meiren","email":"walter@meiren.dev"},"bugs":{"url":"https://github.com/curioswitch/curiostack/issues"},"license":"MIT","readme":"# @curiostack/nunjucks-extended\n\nAn extended version of [mozilla/nunjucks](https://github.com/mozilla/nunjucks),\nwith some extra convenience methods added on.\n\n## Usage\n\n### Import\n\nThe default option for importing is, the extended version of `nunjucks` `Environment`.\nAlso `Template`, `Loader`, `FileSystemLoader`, `WebLoader` are available as non-default\nimports.\n\nThe import can be done in other `curiostack` `yarn` modules  using the package name\n`@curiostack/nunjucks-extended`. It can work outside of curiostack as well, but your project\nmust use typescript and be configured to compile this module.\n\n```typescript\nimport Environment, { Template, Loader, FileSystemLoader, WebLoader } from '@curiostack/nunjucks-extended';\n// no need for require('nunjucks')\n\nconst env = new Environment();\n// alternatives:\n// const env = new Environment(new FileSystemLoader('/some/path'));\n// const template = new Template('Hello {{ username }}', env);\n// etc ...\n```\n\n### API\n\nThe underlying API of each available `nunjucks` class is unchanged, so you can\n[use the official docs](https://mozilla.github.io/nunjucks/getting-started.html) for reference.\n\n## Environment\n\nThe [nunjucks Environment](https://mozilla.github.io/nunjucks/api.html#environment)\nclass still functions as before. It just has been extended with some extra functionality.\n\n```typescript\nimport Environment from '@curiostack/nunjucks-extended';\n\nconst env = new Environment();\n// ...\n\nconst result = env.render('template.njk');\n// `result` is rendered with all of the base `nunjucks.Environment` logic\n//   as well as the extended `curiostack` `Environment` functionality\n```\n\n### Filters\n\nThe `Environment` object is extended with some extra convenience filters.\n\n#### allAfterLine(lineMatcher: string, [exactMatch: boolean])\n\nScans the content of a multiline text and returns all the text after a line\nmatching a `regex` expression.\n\nIf `exactMatch` is `true`, a line will be matched only when all of it matches\nthe `regex` expression exactly.\n\n##### input\n\n```\n{{ 'foo\\n_@@_\\nbar\\nbaz' | allAfterLine('@') }}\n{{ 'foo\\n_@@_\\nbar\\nbaz' | allAfterLine('^_@@_$', true) }}\n```\n\n##### output\n\n```\nbar\\nbaz\nbar\\nbaz\n```\n\n#### allBetweenLines(lineMatcher: string, [exactMatch: boolean])\n\nScans the content of a multiline text and returns all the text between two lines\nmatching a `regex` expression.\n\nIf `exactMatch` is `true`, a line will be matched only when all of it matches\nthe `regex` expression exactly.\n\n> If multiple blocks are found, all of them are joined together with a newline (`\\n`)\n> and returned as one block.\n\n##### input\n\n```\n{{ 'foo\\n_@@_\\nbar\\nbaz\\n_@@_\\nfoz' | allBetweenLines('@') }}\n{{ 'foo\\n_@@_\\nbar\\nbaz\\n_@@_\\nfoz' | allBetweenLines('^_@@_$', true) }}\n{{ 'foo\\n_@@_\\nbar\\nbaz\\n_@@_\\nfoz\\n_@@_\\nbop\\n_@@_\\nbap' | allBetweenLines('@') }}\n```\n\n##### output\n\n```\nbar\\nbaz\nbar\\nbaz\nbar\\nbaz\\nbop\n```\n\n### Testing\n\n`jest` is used for tests, and can be run with the following command.\n\n```shell\n./gradlew :common:web:nunjucks:yarn_test\n```\n\n### Style\n\n`eslint` with `curiostack` rules is used for controlling code style, and can be run\nwith the following command.\n\n```shell\n./gradlew :common:web:nunjucks:yarn_lint\n# output linting problems\n\n./gradlew :common:web:nunjucks:yarn_lint_--fix\n# automatically fix linting problems, and output problems which can't be auto-fixed\n```\n","readmeFilename":"README.md"}