{"id":21401456,"url":"https://github.com/spoonx/procurator","last_synced_at":"2025-07-30T05:06:28.077Z","repository":{"id":149466118,"uuid":"85287206","full_name":"SpoonX/procurator","owner":"SpoonX","description":"A tiny, stream based replacement template engine.","archived":false,"fork":false,"pushed_at":"2018-10-17T18:58:03.000Z","size":29,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-13T21:37:24.862Z","etag":null,"topics":["stream","template-engine","templating"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SpoonX.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-17T08:15:02.000Z","updated_at":"2019-08-16T11:09:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"613965b4-6673-4fd3-a7db-c09b09674b4b","html_url":"https://github.com/SpoonX/procurator","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/SpoonX/procurator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fprocurator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fprocurator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fprocurator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fprocurator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpoonX","download_url":"https://codeload.github.com/SpoonX/procurator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpoonX%2Fprocurator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267814689,"owners_count":24148328,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["stream","template-engine","templating"],"created_at":"2024-11-22T15:27:55.611Z","updated_at":"2025-07-30T05:06:28.048Z","avatar_url":"https://github.com/SpoonX.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# procurator\n\nA tiny, super fast, stream based replacement template engine written in typescript. **Now recursive! (keep reading to learn what that means)**\n\nThis module has few features.\n\n* Simple variables\n* Defaults for variables\n* Support for nested placeholders (recursive)\n* Support for nested variables (Using [homefront](https://github.com/SpoonX/homefront))\n\n## Installation\n\nSimply use your package manager of choice.\n\n* `npm i --save procurator`\n* `yarn add procurator`\n\n## Usage\n\n`procurator(parameters[, recursive = true, limit = 100])`\n\nCode speaks. Let's do this.\n\n**some.template.js**\n\n```js\nmodule.exports = {\n  // Simple replace\n  hello: '{{ foo }}',\n\n  // With a default\n  cake: '{{ bar : lies }}',\n\n  // Defaults get trimmed, let's use quotes\n  bacon: '{{ bat : ' holds the truth ' }}',\n\n  // Let's use double quotes\n  empire: '{{ baz:\"I haz\\'s one\" }}',\n\n  // Let's default to an empty string\n  hello: '{{ foo: }}',\n\n  // Whaaaaaat, nested keys!?\n  username: '{{ user.name:\"Guest\" }}',\n};\n```\n\n**app.js**\n\n```js\nconst { stream } = require('procurator');\nconst fs         = require('fs');\n\nlet readStream  = fs.createReadStream('./some.template.js');\nlet writeStream = fs.createWriteStream('./out-file.js');\nlet parameters  = {foo: 'Batman', bat: 'is holy', user: {name: 'Swag-meister'}};\nlet recursive   = true; // New: replace more than once to allow for nested variables\nlet limit       = 100; // New: the maximum replacement depth. Throws an Error when reached.\n\nreadStream.pipe(stream(parameters, recursive, limit)).pipe(writeStream);\n```\n\n**Produces ./out-file.js:**\n\n```js\nmodule.exports = {\n  // Simple replace\n  hello: 'Batman',\n\n  // With a default\n  cake: 'lies',\n\n  // Defaults get trimmed, let's use quotes\n  bacon: 'is holy',\n\n  // Let's use double quotes\n  empire: 'I haz one',\n};\n```\n\n_**Note**: The file extension doesn't matter. I used .js but it can be anything._\n\n### Sync\n\n`procurator(target, parameters[, recursive = `true, limit = 100])`\n\nSometimes you just want to apply replaces in memory.\nFor that purpose, a memory and code-size efficient method has been added.\n\n```js\nconst procurator = require('procurator');\nconst target     = 'Hello {{addressed: \"world\"}}! How are you doing {{ when: \"today\"}}?';\nconst recursive  = true; // New: replace more than once to allow for nested variables\nconst limit      = 100; // New: the maximum replacement depth. Throws an Error when reached.\n\nconsole.log(procurator.replace(target, {addressed: 'developer'}, recursive, limit));\n\n// Outputs: Hello developer! How are you doing today?\n```\n\n### Nested placeholders\n\nAs of v2.0.0, Procurator supports nested placeholders.\nThis means you can do the following (using sync for simplicity):\n\n```js\nconst procurator = require('procurator');\nconst target     = 'Hello {{addressed: \"{{title: \"Mr.\"}} world\"}}! How are you doing {{ when: \"today\" }}?';\nconst recursive  = true; // New: replace more than once to allow for nested variables\nconst limit      = 100; // New: the maximum replacement depth. Throws an Error when reached.\n\nconsole.log(procurator.replace(target, {title: 'Mrs.'}, recursive, limit));\n\n// Outputs: Hello Mrs. world! How are you doing today?\n```\n\nThis also works for parameters themselves; \nmeaning that you can replace placeholders with strings that also contain placeholders.\n\n## Known limitations\n\n### Multi line placeholders\n\nIt's currently not possible to spread a placeholder over multiple lines.\nIf you have a use case for this please create an issue.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspoonx%2Fprocurator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspoonx%2Fprocurator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspoonx%2Fprocurator/lists"}