{"_id":"stach","_rev":"3-04eff94b57e892ae8345f19e57086fae","name":"stach","dist-tags":{"latest":"2.0.1"},"versions":{"1.0.0":{"name":"stach","version":"1.0.0","description":"Minuscule mustache-like string templating system for node or browsers.","main":"./dist/stach.es2017.cjs","module":"./dist/stach.es2020.mjs","unpkg":"./dist/stach.es2017.min.js","types":"./dist/stach.d.ts","scripts":{"reset":"rm -rf node_modules && npm i","clean":"rm -rf dist","build":"tsbundle build","publish":"tsbundle publish"},"repository":{"type":"git","url":"git+https://github.com/zouloux/stach.git"},"keywords":["small","tiny","mustache","templating","template","node","browser"],"author":{"name":"Alexis Bouhet - ZoulouX"},"license":"MIT","bugs":{"url":"https://github.com/zouloux/stach/issues"},"homepage":"https://github.com/zouloux/stach#readme","devDependencies":{"@types/node":"^18.0.3","@zouloux/tsbundle":"^1.2.17"},"tsbundle":{"exportMap":{"Stach":"./stach"},"files":[{"output":"./dist/","input":"./src/stach.ts","exportBits":true}]},"gitHead":"e4e87cab8fe0006fb034757ebfb271d311171bc1","_id":"stach@1.0.0","_nodeVersion":"17.2.0","_npmVersion":"8.1.4","dist":{"integrity":"sha512-spXGZC11W47uDHs43ntfOLz4ey6J/xupRKu35kfcGwSbkpP4YMlSdDwVHE2k2FzT68TtyPYdKwBqc1dDubESow==","shasum":"896095476989db2646ef41c3475fcad96819acf0","tarball":"https://registry.npmjs.org/stach/-/stach-1.0.0.tgz","fileCount":6,"unpackedSize":15167,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDhe/bhk3h66vPjeZxY+q524Wp+kdicPlQz4QfuEjBgJQIgCr/AroHyHMsgI03wi/MiMN+Lb91wR9JlvDKKlChBx7Q="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi0TtsACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqM0w/9FcSJuxJNi//eiN0fy+f/hbsZgIuWc7BGgt0vy7Bs9cEN1gTn\r\nudTN8W6YI8qdTX5UaQlbWOrtZDb5SwTtwFWqTb8V8EfOkGlN1QLm0CDR7D10\r\nwlBXwRRsWvLiywfRVRBDbYy0Y8KZJ2Gi6mwQ4EhuOH75amScI0fw0LLz/Upn\r\nhrGqyOPklHUw98f0VmWQwqfDer2yLxpJ8N4zp3G+KdPFy156HIGqWj6v78di\r\nhhGQXCqzQgRapX0L6Q7sik9yDaAm5ZHxeyXiPNrP5N4CB0HwbMzEUYQnxQ88\r\nBk5FMch6xVLiV7FfQ22pkhc5VTF2e0TzfjHv7v24xNC2+cvYZWGW4yaapIg+\r\nYYNgq8C0e8SCsiUJiJ9zqqd7cPjowor2aCSAEvseycWLlhqmkQARD1I6XkFt\r\ns7h1JK9gknJ9R4DCvsdpJukCD+azeyHfAZ2T+slIubOQyuT3V/2KI9p5hNS8\r\n0ideB/pwYTiLB0pKDscdB+gLmUaOFYXwl0c+39df9Vab1Df96tpzVbtXfeFl\r\nEeiEe6FVVIOp4iYHcyxxtiAhuiA6IJ2D5My/b4fUGK0EcCGa+tisdsMWq1xw\r\nBnNTIJwTqPX3YM85gfb9NHInpDVkH/H3zN8rlpcfH7uMLewXv3DDyI1A0h3Q\r\nw+1xssU5SdeS5j34vNhv08yL2zJTsVtlH2s=\r\n=qB3W\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"zouloux","email":"alex@zouloux.com"},"directories":{},"maintainers":[{"name":"zouloux","email":"alex@zouloux.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stach_1.0.0_1657879404150_0.8034007352474606"},"_hasShrinkwrap":false},"1.0.1":{"name":"stach","version":"1.0.1","description":"Minuscule mustache-like string templating system for node or browsers.","main":"./dist/stach.es2017.cjs","module":"./dist/stach.es2020.mjs","unpkg":"./dist/stach.es2017.min.js","types":"./dist/stach.d.ts","scripts":{"reset":"rm -rf node_modules && npm i","clean":"rm -rf dist","build":"tsbundle build","publish":"tsbundle publish"},"repository":{"type":"git","url":"git+https://github.com/zouloux/stach.git"},"keywords":["small","tiny","mustache","templating","template","node","browser"],"author":{"name":"Alexis Bouhet - ZoulouX"},"license":"MIT","bugs":{"url":"https://github.com/zouloux/stach/issues"},"homepage":"https://github.com/zouloux/stach#readme","devDependencies":{"@types/node":"^18.0.3","@zouloux/tsbundle":"^1.2.17"},"tsbundle":{"exportMap":{"Stach":"./stach"},"files":[{"output":"./dist/","input":"./src/stach.ts","exportBits":true}]},"gitHead":"c2fbcae9df4da94cac2307217fa76c85dbf3de23","_id":"stach@1.0.1","_nodeVersion":"17.2.0","_npmVersion":"8.1.4","dist":{"integrity":"sha512-jPQjmoPKqzKBvZPqg9zDAWcx0sLUfFuXYu4w0nR2rac1zXy/vhOGRbGZ2yhdR39vd5rpRSuOLwVj46PUxpLekw==","shasum":"c50148b9dd33160bac69849a5bc29dbee1214500","tarball":"https://registry.npmjs.org/stach/-/stach-1.0.1.tgz","fileCount":7,"unpackedSize":16878,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGobWGFX3cJiEowUcuc492dAhQpkD9fltTDB2T9mMBIYAiBDv5k9l9zhTDFGPni2F23ZKvZMw5jw6j8uUUmk/pfwJA=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi0XJfACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr6pw/9Gx+/wFcvBBGKnUXozVmUj/GokqCkf1kNWOk/vYkcbeoXcVHJ\r\naiTCrkGV1NnnbJVv1nx7xoiTREM4LQ9ignalGHXb+BfDmL2I2En79gHY5U9f\r\n5OixvFtMhbRazOYUp9STj3HLBWvEAedVxShDQTYS8Iv75M1/V7HPry5zu02x\r\nAqcKRZkb/BvkfOBia0UnjaoiREmyqzOZTSN0V8bx+LlyHowhA4IeDIws3E/k\r\nTC1RlVyCax7MaBKk5Js3atz1JMNd3QevMu5jjSyXKpksQ333WUtyLCcqk+vf\r\nE6DCCD7DiZKft0cxK4LI0/Qwxpj5N0GSrSlJ+xz0ckQCHhkPSOKvKFadjyoR\r\niYwkOUceMnnGHifMaNVSpRazhKjt3Q63Hb93Hy49Hy3VDHpCdgfbgJctR11I\r\neXh2P2fr0ZTTnamoNiKCFSQ1YUVvdDu23LCK46Kl+Oy9Ek3/Fi0CqK3ECGyk\r\ncMpkXpxGO3IkKJeHOQ24THbg7SvMukRREcPcfBG2hHI4Yu5vVXr+PtdabHnL\r\no1LwBVRRvDeGlPvK1GmZf93P9qAvjCKYBSS5PnISC+uCcKW/6WXuXTu+zmiS\r\nadAqEkAc5NGqmURF6TEHyTRr0nGfwGcZ9mL8aExF4afz9m1yTnKxl6ih7pQB\r\nGgdpgwGewpzqu6NbDj2sAsHjmtLEqoCX0q0=\r\n=aa2c\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"zouloux","email":"alex@zouloux.com"},"directories":{},"maintainers":[{"name":"zouloux","email":"alex@zouloux.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stach_1.0.1_1657893471636_0.644811737424166"},"_hasShrinkwrap":false},"2.0.0":{"name":"stach","version":"2.0.0","description":"Minuscule mustache-like string templating system for node or browsers.","main":"./dist/stach.es2017.cjs","module":"./dist/stach.es2020.mjs","unpkg":"./dist/stach.es2017.min.js","types":"./dist/stach.d.ts","scripts":{"reset":"rm -rf node_modules && npm i","clean":"rm -rf dist","test":"node test/test.mjs","build":"tsbundle build","publish":"tsbundle publish"},"repository":{"type":"git","url":"git+https://github.com/zouloux/stach.git"},"keywords":["small","tiny","mustache","templating","template","node","browser"],"author":{"name":"Alexis Bouhet - ZoulouX"},"license":"MIT","bugs":{"url":"https://github.com/zouloux/stach/issues"},"homepage":"https://github.com/zouloux/stach#readme","devDependencies":{"@types/node":"^18.6.2","@zouloux/cli":"^0.1.7","@zouloux/tsbundle":"^1.3.0"},"tsbundle":{"exportMap":{"Stach":"./stach"},"files":[{"output":"./dist/","input":"./src/stach.ts","exportBits":true}]},"gitHead":"59e24d85bd1a854f6b27bd409682ef65692fff10","_id":"stach@2.0.0","_nodeVersion":"17.2.0","_npmVersion":"8.1.4","dist":{"integrity":"sha512-DnXxsMXgXFx1jgI9RFirh6TexwWgEcAEz6QOI98RKIZ60wkA6NfJ18eg6x+vK4sniBkGIyY3CDsioGEfTIteXw==","shasum":"1702e8f5f3853d7e347313662a2616b8aff57f6f","tarball":"https://registry.npmjs.org/stach/-/stach-2.0.0.tgz","fileCount":8,"unpackedSize":19265,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCdVaTfsn4Gr2/iLNq9gQYpyCzHvlqE1ussqaUGoZvp5AIhAOTjluMjgkiGd9oWhD40TRNd8D2U/BbFKXcZ8hlvKml2"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi48WgACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmrekg//eUZqndzDY3wq7Ydt3Kvs6AQNmy6O5eiMUd7Howr6qVE54+PD\r\n1Fg90aZ/3IJX8OLFPuElnLFC/tTqbtjVFMkfhjFylWo11PSAz9vWWCnLQvyK\r\n6csizYRoWtGGllSz54MNNX2C1Iu+r2m2gzTBkaCftHhcBHvNcQnkg45FkC13\r\nd6ZMyauS2yHH1LFgT14eOXoo3Idxx7k5JLDiD+GHsrmAhvYpgZDcjQgHbcUi\r\nc9vQfqVeIRKosQxSFXDia7gXHl1mKI/66wOKIoTDhqubMuIVSgVT0xTUKthh\r\nWMnc+BXkXwuCvjUZ0uCBL11FMViKctveM1JAMHosdNdpIO9GAoSYsdEo9KJx\r\ns8AePYaXJs4fI+6H0OAZCuy9O7cd9F/WGjePTcXN+rfFao64TGMIBiEcyLa+\r\nEFe76ufsNUSVPXkkeNHoyTPtxcChGq1DCjMEOelNdzwGNVXyWXT7cu6tbv1a\r\nDoGoCp+D9K4R3FYZcyxdl6dcvmZe9CS+0W/gVxcB5CixHRmerMNcuXGZuV8H\r\njenmNvHD994q/HZU+wnfze8hbvNXCN503ConwGIOdJ9YbGlHdYA7vBwofVC9\r\nwEz7MVvcrO8xt4Hgeiigpy1Z8KM0UsBpvOUfQef0tYNJHjmR/GxRvh129/iw\r\nk6Hmk/sFhV76nUUXAfs5wlIQC5OJmlGPmb0=\r\n=OcQx\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"zouloux","email":"alex@zouloux.com"},"directories":{},"maintainers":[{"name":"zouloux","email":"alex@zouloux.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stach_2.0.0_1659094432734_0.969678894563752"},"_hasShrinkwrap":false},"2.0.1":{"name":"stach","version":"2.0.1","description":"Minuscule mustache-like string templating system for node or browsers.","main":"./dist/stach.es2019.cjs","module":"./dist/stach.es2022.mjs","unpkg":"./dist/stach.es2017.min.js","types":"./dist/stach.d.ts","scripts":{"reset":"rm -rf node_modules && npm i","clean":"rm -rf dist","test":"node test/test.mjs","build":"tsbundle build","publish":"tsbundle publish"},"repository":{"type":"git","url":"git+https://github.com/zouloux/stach.git"},"keywords":["small","tiny","mustache","templating","template","node","browser"],"author":{"name":"Alexis Bouhet - ZoulouX"},"license":"MIT","bugs":{"url":"https://github.com/zouloux/stach/issues"},"homepage":"https://github.com/zouloux/stach#readme","devDependencies":{"@types/node":"^18.6.2","@zouloux/cli":"^0.1.7","@zouloux/tsbundle":"^1.3.0"},"tsbundle":{"exportMap":{"Stach":"./stach"},"formats":["es2019.cjs","es2022.mjs","es2017.min.js"],"files":[{"output":"./dist/","input":"./src/stach.ts","exportBits":true}]},"gitHead":"e55edea3158b7df431ee138219b4a00706365446","_id":"stach@2.0.1","_nodeVersion":"17.2.0","_npmVersion":"8.1.4","dist":{"integrity":"sha512-elbZHaluwJ7xfXyJtgYXWphDjjtZ6luc/QBOmYEp6F4kHGocZq5Qz3Pd9Q7Aanmb1mXRM0rgRADkqQelLi2WCw==","shasum":"745990b1be48e39af334e6c0e8da39c137470aec","tarball":"https://registry.npmjs.org/stach/-/stach-2.0.1.tgz","fileCount":8,"unpackedSize":19351,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCslcXDom+4WT/Ez0tYS5H+7kWxyxi5W71DUa6vu2I+EAIhAIYo6iSON1V8ZC/AffjkGFXYQTz6yuci5oIs7rjL7Pp2"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJi7NUAACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqTFQ//XzYUO2No6J/+V1yQRqRjTvADCbnGfX42Damcp2Luj1rucfmL\r\n3O634UkRDUy5ngm/K2orFUbqMsMQZL/9yMAiN0E0M7jIhDXriDp0zNKcWuIf\r\n5sGnH4dg2hE0uPqy+lyRYY8lTXKnUeWCQ/qulnT1Rvmb3C8uFWgY87kj/Ork\r\naV9bLWiFJrYNuQ6uZJK0DGnh0r8Rhip3j+aVtyfRXddpl3nKXpPsjJKbkEpp\r\nHGvZLV7ZoQppS8tUBG1b2I6S/5eC9fTqG9Sx8myo2m4Q48ZlEkwT7UUHK735\r\nC6C/eJome04vk/QbJJ0H5DIIcv9c30ftXV9ye7GpRhB91955IX4AbLZqNpob\r\nyhTfnMAoFoKjZQ/riU9pZ8BDzKrr8ZanVUsEniA2jM+m9VQrlAa/BMK619gl\r\noABS9ppfb6nVP83GYBGbONXBGhrtBRmG1qt1LXaJx3yS4AJ0g+9Jeid/nYaG\r\nCkvmLWK5MPUu+W/UFeaq55Rht22uW2T0lS/qPgGisLyAFWU16ZAbOWOGrM6W\r\nrBo5ASwacsrGdkluAwOQu2OHQChBu2bbGS4iOs0xvs8cFRGgcrKE0RUYZqqp\r\nVdhrCtpM9r1gkTkWSarAuYTzjNEOgpym1zw36U6SNZInKa1c2eObYn/F0pix\r\nBje/IxEppsy05s6AKU7aZWLeQBPRgz/g6QM=\r\n=oVbD\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"zouloux","email":"alex@zouloux.com"},"directories":{},"maintainers":[{"name":"zouloux","email":"alex@zouloux.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stach_2.0.1_1659688192009_0.654844938937468"},"_hasShrinkwrap":false}},"time":{"created":"2022-07-15T10:03:24.090Z","1.0.0":"2022-07-15T10:03:24.311Z","modified":"2022-08-05T08:29:52.253Z","1.0.1":"2022-07-15T13:57:51.856Z","2.0.0":"2022-07-29T11:33:52.913Z","2.0.1":"2022-08-05T08:29:52.185Z"},"maintainers":[{"name":"zouloux","email":"alex@zouloux.com"}],"description":"Minuscule mustache-like string templating system for node or browsers.","homepage":"https://github.com/zouloux/stach#readme","keywords":["small","tiny","mustache","templating","template","node","browser"],"repository":{"type":"git","url":"git+https://github.com/zouloux/stach.git"},"author":{"name":"Alexis Bouhet - ZoulouX"},"bugs":{"url":"https://github.com/zouloux/stach/issues"},"license":"MIT","readme":"\n# stach\n\n__Stach__ is a ![](./bits/stach.es2017.min.js.svg) __mustache-like__ string __templating__ system for __Node__ or __Browsers__.\n\n```typescript\nimport { Stach } from \"stach\"\n\nconst templated = Stach(\"Hello {{name}} 😸\", {name: \"mr Bond\"})\nconsole.log( templated ) // Hello mr Bond 😸\n```\n\n## Concept\n\nWhy do we need __Stach__ with literal template strings available everywhere ?\nStach can be useful when any **small templating** is needed when **the template source is not coming from javascript** itself.\n<br>For example, if you need to __process a template__ from a __user generated file__, __a dictionary__, or any other kind of input.\n\nStach is ultra-lightweight and compatible with Node and Browsers environments.\nIt uses Javascript's Regex based `String.replace` function to be **super effective**.\nIt's also compatible with multiline files / inputs.\nTypescript definitions are included ✌️\n\n### Scope\n\nStach can do __variable replacement__, __function calls__, and __short ternary evaluations__. **THAT'S IT.**<br>\nIt **cannot** do advanced conditions, listing, HTML transformations, etc...\nIf you need all of this, check others template engines like [Mustache](https://mustache.github.io/), [Handlebars](https://handlebarsjs.com/) or even [React JSX](https://fr.reactjs.org/docs/introducing-jsx.html) in some cases.\n\n### Installation\n\nTo install Stach in your project :<br>\n- NPM : `npm install stach`\n- Yarn : `yarn add stach`\n\n### Usage\n\nIf you are using CommonJS syntax :\n```javascript\nconst { Stach } = require('stach')\n```\n\nBetter, if ES-Modules syntax is available :\n```javascript\nimport { Stach } from 'stach'\n```\n\n### Simple variable replacement\n\n```javascript\nStach('Hello {{username}}', {\n    username: 'James Bond'\n});\n// 'Hello James Bond'\n```\n\n### Values can be functions\n\n```javascript\nconst user = { balance : 12 };\nStach('Your current balance is {{balance}}€', {\n    balance: () => user.balance\n});\n// 'Your current balance is 12€'\n```\n\n### Ternary conditions can be used :\n\n```javascript\nStach('Condition is {{test ? truthy : falsy}}', {\n    test: 0\n});\n// 'Condition is falsy'\n```\n\n### Or, with the help of functions :\n```javascript\nStach('{{name}} is {{age}} {{isAgePlural ? years : year}} old', {\n    name: 'Brad Pitt',\n    age: 55,\n    // Note that v here is the current value object\n    // So we can access dynamically to the age property\n    isAgePlural: v => v.age > 1\n});\n// 'Brad Pitt is 55 years old'\n```\n\n### More functions\n\n```javascript\nStach('{{plainFunction}} == 15', {\n    value: 15,\n\t// This works\n    plainFunction () {\n        return this.value;\n    }\n});\n// '15 == 15'\n```\n\n### Complex example mixing functions and ternaries\n\n```javascript\nconst user = {\n    name: 'James Bond',\n    gender: 'male',\n    balance: 15\n}\nStach('Hello {{ isMale ? mr : mrs }} {{ getLastName }}. Your balance is {{ balance }}€.', {\n  ...user,\n  isMale: v => v.gender == 'male',\n  getLastName: v => v.name.split(' ')[1]\n});\n// 'Hello mr Bond. Your balance is 15€.'\n```\n\n### Advanced, delimiters regex can be changed\n\nHere is the default delimiter regex : `/{{(.*?)}}/gm` [see](https://github.com/zouloux/stach/blob/main/src/stach.ts#L5)\n\nThis will set delimiters from `{{var}}` to `{var}`.\nUse [regexr.com](https://regexr.com) to create easily your delimiter's Regex.\n\n```javascript\nconst singleCurlyRegex = /{(.*?)}/gm \t// regex for single curly braces\nconst template = 'Hello { username }' \t// template using single curly braces\nconst data = { username: 'Mr Bond' }\nStach( template, data, singleCurlyRegex ); // \"Hello Mr Bond\" \n```\n\n### Unpkg\n\nStach is available on [unpkg](https://unpkg.com/stach)\n\nUsage :\n```html\n<script src=\"https://unpkg.com/stach@1.0.0/dist/stach.es2017.min.js\"></script>\n<script>\n\tStach(\"Hello from {{name}} !\", { name: 'unpkg' })\n</script>\n```\n\n### Built\n\n__Stach__ is built from __typescript__ thanks to [tsbundle](https://github.com/zouloux/tsbundle)\n\n### TODO / Not working\n\nWe need a way to escape `{{` when templating code-like files or simply keep not found variables.\n\nEx :\n```typescript\nconst source = `\n\t...\n\tconst Test{{FileName}} = \"Source {{doNotReplace}}\"\n\t...\n`\nStach( source, {\n\tFileName : \"Replace\" \n})\n```\nwill try to replace `{{doNotReplace}}` which is something to keep in output.","readmeFilename":"README.md"}