{"name":"jazz","version":"1.0.0","keywords":["template"],"author":{"url":"https://cliffano.com","name":"Cliffano Subagio","email":"blah@cliffano.com"},"license":"MIT","_id":"jazz@1.0.0","maintainers":[{"name":"cliffano","email":"cliffano@gmail.com"}],"contributors":[{"url":"https://github.com/cliffano/jazz/graphs/contributors","name":"All contributors"}],"homepage":"https://github.com/cliffano/jazz","bugs":{"url":"https://github.com/cliffano/jazz/issues"},"bin":{"jazz":"bin/jazz.js"},"dist":{"shasum":"dde755a83eff06687b130fbba34e36fd5b9edb99","tarball":"http://registry-npm.ywwl.com/jazz/download/jazz-1.0.0.tgz","fileCount":62,"integrity":"sha512-PJt43IB5joyLQxLAizq22Z+SVEWqxT3A2Z/f2FCBwNFfJH1O+lw+/MBeJKNbzFA/WjvJWgFxXXp0rpEKg2pxRQ==","signatures":[{"sig":"MEUCIAVLUemHQ99xWxMY9XIbHfqFs+bt1If9jHygrGDCBPpAAiEA5mzw1BurbOg8oOVRXEOnquPbzpXWfx7EqlalGO8m/+Q=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/jazz@1.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":129279,"size":35752,"noattachment":false,"key":"/jazz/-/jazz-1.0.0.tgz"},"main":"./lib/jazz","type":"module","engines":{"node":">= 20.0.0"},"gitHead":"b735e373f45046d2168577baeaa5569d2999820a","scripts":{},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9643200e-f3c6-4607-9e70-c8ae6357a94c"}},"repository":{"url":"git+https://github.com/cliffano/jazz.git","type":"git"},"_npmVersion":"11.13.0","description":"A minimalistic template engine with zero runtime dependency","directories":{"bin":"./bin","lib":"./lib","test":"./test"},"_nodeVersion":"26.2.0","preferGlobal":true,"_hasShrinkwrap":false,"devDependencies":{"sinon":"^21.0.0","esmock":"^2.7.3","@sinonjs/referee":"^11.0.1"},"_npmOperationalInternal":{"tmp":"tmp/jazz_1.0.0_1779603185336_0.6618232317277377","host":"s3://npm-registry-packages-npm-production"},"readme":"<!-- BEGIN:AVATAR -->\n![Avatar](avatar.jpg)\n<!-- END:AVATAR -->\n\n<!-- BEGIN:BADGES -->\n[![Build Status](https://github.com/cliffano/jazz/workflows/CI/badge.svg)](https://github.com/cliffano/jazz/actions?query=workflow%3ACI)\n[![Dependencies Status](https://img.shields.io/librariesio/release/npm/jazz)](https://libraries.io/npm/jazz)\n[![Code Scanning Status](https://github.com/cliffano/jazz/workflows/CodeQL/badge.svg)](https://github.com/cliffano/jazz/actions?query=workflow%3ACodeQL)\n[![Coverage Status](https://coveralls.io/repos/github/cliffano/jazz/badge.svg?branch=main)](https://coveralls.io/r/cliffano/jazz?branch=main)\n[![Security Status](https://snyk.io/test/github/cliffano/jazz/badge.svg)](https://snyk.io/test/github/cliffano/jazz)\n[![Published Version](https://img.shields.io/npm/v/jazz.svg)](https://www.npmjs.com/package/jazz)\n<!-- END:BADGES -->\n\n# Jazz\n\nJazz is a minimalistic template engine with zero runtime dependency.\n\nOne of the OG template engines with first commit from 2010.\n\n## Installation\n\n```shell\nnpm install jazz\n```\n\n## Usage\n\n```javascript\nimport jazz from \"jazz\";\nimport sys from \"sys\";\n\nconst template = jazz.compile(\"my template source code {someVariable}\");\ntemplate.eval({\"someVariable\": \"lolmuffin\"}, function(data) { sys.puts(data); });\n```\n\nThis example would output the following:\n\n```text\nmy template source code lolmuffin\n```\n\n### Printing variables\n\n```text\n{someVariable}\n```\n\nThis works for any type of expression, so the following should also work:\n\n```text\n{users.fred}\n{\"hello\"}\n{45}\n{a eq b}\n```\n\n### Filter functions\n\nYou can call filter functions like so:\n\n```text\n{someFilter(arg1, arg2)}\n```\n\nFilter functions are statements, NOT expressions so they cannot be chained\nnor used in if/forelse/etc. tests. However, calls can be made on any type\nof expression -- e.g.\n\n```text\n{math.sin(45)}\n```\n\n### Implementing filter functions\n\nFilter functions may block so rather than returning the value you want\nrendered as you might in other frameworks, jazz passes in a callback to\nyour filter function that you then call to indicate that you have a\nresult. e.g. here we simulate a blocking operation using setTimeout().\n\n```text\n// sum.jazz\n\n{sum(5, 10)}\n```\n\n```javascript\n// sum.js\n\nimport jazz = from \"jazz\";\n\nconst params = {\n    sum: function(arg1, arg2, cb) {\n        setTimeout(function() {\n            cb((arg1 + arg2).toString());\n        }, 2000);\n    }\n}\njazz.compile(\"sum.jazz\").eval(params, function(output) { console.log(output); });\n```\n\nNote that even though the execution of the callback is delayed, this example still\nworks.\n\n### Conditional Statements\n\nYou can check if a variable evaluates to a true value like so:\n\n```text\n{if name}\n    Hello, {name}\n{end}\n```\n\nElse clauses are also supported:\n\n```text\n{if name}\n    Hello, {name}\n{else}\n    Hello, Captain Anonymous\n{end}\n```\n\nAs are else..if clauses:\n\n```text\n{if firstName}\n    Hello, {firstName}\n{elif lastName}\n    Hello, Mr. {lastName}\n{else}\n    Hello, Captain Anonymous\n{end}\n```\n\nLimited logical expressions are also possible:\n\n```text\n{if user.lastName and user.isVip}\n    Hello, Mr. {user.lastName}, my good man!\n{end}\n\n{if fred.tired or fred.bored}\n    Fred: \"Yawn!\"\n{end}\n\n{if not awake}\n    Zzz\n{end}\n```\n\neq & neq comparison operators are available for comparing two values:\n\n```text\n{if config.feature eq \"enabled\"}\n    Feature is enabled!\n{end}\n\n{if status neq \"inactive\"}\n    Huzzah!\n{end}\n```\n\nYou can also group expressions using parentheses:\n\n```text\n{if (a and b) or c}\n    ...\n{end}\n```\n\n### Looping over an array\n\n```html\n{foreach item in someArray}\n    <p>{item}</p>\n{end}\n```\n\nThe value being iterated over can be any expression supporting\nan Array-like interface.\n\n### Looping over an object\n\n```html\n{foreach pair in someObject}\n    <p>{pair.key} = {pair.value}</p>\n{end}\n```\n\n### Synchronous functions\n\n```html\n{if @blah('a')}\n    <p>There were so many blahs in a</p>\n{end}\n```\n\nThe function is provided to the template the same way asynchronous functions are, just with a return instead of a cb.\n\n### Loop counters / index\n\n```html\n{foreach pair in someObject}\n    <p>Loop number (1 based): {__count}</p>\n    <p>Index (0 based): {__index}</p>\n    <p>{pair.key} = {pair.value}</p>\n{end}\n```\n\n### Looking into arrays/objects\n\n```html\n<p>{object['array'][0].cheese}</p>\n```\n\n## Credits\n\nJazz was created by the brilliant Thomas Lee and Daniel Brain during the era of Shine Technologies early adoption of node.\n\n## Colophon\n\n<!-- BEGIN:DEVELOPERS_GUIDE -->\n[Developer's Guide](https:/cliffano.github.io/developers-guide-nodejs.html)\n<!-- END:DEVELOPERS_GUIDE -->\n\n<!-- BEGIN:BUILD_REPORTS -->\nBuild reports:\n\n* [Code complexity report](https://cliffano.github.io/jazz/complexity/plato/index.html)\n* [Unit tests report](https://cliffano.github.io/jazz/test/mocha.txt)\n* [Test coverage report](https://cliffano.github.io/jazz/coverage/c8/index.html)\n* [Integration tests report](https://cliffano.github.io/jazz/test-integration/mocha.txt)\n* [API Documentation](https://cliffano.github.io/jazz/doc/jsdoc/index.html)\n\n<!-- END:BUILD_REPORTS -->\n","publish_time":1779603185496,"_cnpm_publish_time":1779603185496,"dist-tags":{"latest":"1.2.0"}}