{"id":29023008,"url":"https://github.com/bamlab/kettle","last_synced_at":"2025-06-26T03:04:57.750Z","repository":{"id":36399171,"uuid":"188010331","full_name":"bamlab/kettle","owner":"bamlab","description":"Kettle - The templating engine for boilerplates","archived":false,"fork":false,"pushed_at":"2023-01-06T02:18:15.000Z","size":1442,"stargazers_count":5,"open_issues_count":15,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-01T16:30:56.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bamlab.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-05-22T09:50:37.000Z","updated_at":"2024-03-18T04:34:53.000Z","dependencies_parsed_at":"2023-01-17T01:15:43.943Z","dependency_job_id":null,"html_url":"https://github.com/bamlab/kettle","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bamlab/kettle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Fkettle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Fkettle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Fkettle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Fkettle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bamlab","download_url":"https://codeload.github.com/bamlab/kettle/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bamlab%2Fkettle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261990349,"owners_count":23241188,"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","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":[],"created_at":"2025-06-26T03:04:57.270Z","updated_at":"2025-06-26T03:04:57.737Z","avatar_url":"https://github.com/bamlab.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kettle\n\nThe templating engine tailored for boilerplates\n\n# Design philosophy\n\nAs templating engines were historically tailored for the needs of server side rendering they allow for powerful integration of conditions, loops, replacements, includes, ... but don't care about breaking syntax.\n\nThe consequence is that when using those engines for boilerplate templating it breaks the code and prevents you from using tools such as linting, typings and unit tests live while templating. Thus, making the development cycle of a boilerplate tedious.\n\nKettle aims to bring the power of templating without breaking any syntax by focusing only on basic tools and leveraging comments available in (almost) any programing language.\n\n# Usage\n\n## Install Kettle\n\n```\nyarn add @bam.tech/kettle\nnpm install @bam.tech/kettle\n```\n\n## Running Kettle\n\nIt is recommended to use Kettle using Gulp\n\n```javascript\nconst { src, dest } = require('gulp');\nconst { transformFactory } = require('kettle');\n\nsrc(['path/to/template'])\n  .pipe(\n    transformFactory({\n      values: {\n        isTrue: true,\n        isFalse: false,\n        appName: 'myApp',\n        functionName: 'myFunction',\n      },\n    })\n  )\n  .pipe(dest('path/to/output'));\n```\n\n## Using Kettle templates in paths\n\nKettle replaces values in paths:\n\n- Input: `path/to/__replace__appName__/file.env` will output `path/to/myApp/file.env`\n\n## To add a folder/file conditionnaly:\n\n- With `path/to/__replace__appName____if__isTrue__/subFolder__if__isTrue__/file.env`, the resulting file will appear in the written file at the path `path/to/myApp/subFolder/file.env`\n\n- With `path/to/__replace__appName__/subFolder__if__isFalse__/file.env`, Kettle will not write any file\n\n- With a `// __include_if_isTrue_` comment, the file will be included and the comment line removed\n\n- With a `// __include_if_isFalse_` comment, the file will not be included in the output at all\n\n- You can also chain conditions with multiple include lines. The position of the comment in the file does not matter\n\n```javascript\n// __include_if_isTrue_\n// __include_if_isFalse_\n\nconst thisFileWillNotBeRendered = true;\n```\n\n## Reverse assertions\n\nIt is possible to reverse assertions using `!`\n\nFor example, `path/to/__replace__appName__/subFolder__if__!isFalse__/file.env` will render `path/to/myApp/subFolder/file.env`\n\n## Using Kettle templates in files\n\nIn files content, Kettle will turn this:\n\n```javascript\nconst import1 = require('path/to/imports1__if__isFalse__/import1.js');\nconst import2 = require('path/to/imports2__if__isTrue__/import2.js');\nconst import2 = require('path/to/imports2__if__!isTrue__/import2.js');\n\n// __if__isTrue__\n__replace__functionName__();\nconsole.log('__replace__appName__');\n// __endif__\n// __if__isFalse__\nshouldNotAppear();\n// __endif__\n// __if__!isTrue__\nshouldNotAppear();\n// __endif__\n```\n\ninto\n\n```javascript\nconst import2 = require('path/to/imports1/import1.js');\n\nmyFunction();\nconsole.log('myApp');\n```\n\n## Supported comment syntax:\n\n- `//`\n- `#`\n- _Please open an issue if you find a comment syntax which doesn't work with Kettle_\n\n## Search and replace\n\nSometimes it is impossible to use characters such as _\"\\_\"_ in strings. To allow for some edge cases, a search and replace tool has been included. **It is recommended to avoid using this method**.\n\n```javascript\ntransformFactory({\n  replaceList: [\n    {\n      from: 'foo',\n      to: 'hello',\n    },\n    {\n      from: 'Bar',\n      to: 'World',\n    },\n  ],\n});\n```\n\nThis will transform all occurences of `foo` and `Bar`. `fooBar` will become `helloWorld`\n\n## Custom replacement blocks\n\nIt is possible to customize the `__replace__\u003cmyVar\u003e__`, `__if__\u003cmyVar\u003e__` and `__endif__` blocks.\n\nExamples are provided in [kettle.replace.test.ts](./src/kettle.replace.test.ts)\n\n## Syntax highlighting\n\n### VSCode\n\nTo highlight Kettle syntax it is advised to install the [VSCode Highlight](https://github.com/fabiospampinato/vscode-highlight.git) plugin and use the following rules in `.vscode/settings.json`:\n\n```json\n{\n  \"highlight.regexes\": {\n    \"(.*?__if__)(!.+?)(__.*?)\\\\n\": [\n      {\n        \"backgroundColor\": \"#a06f5f\",\n        \"color\": \"#FFF\"\n      },\n      {\n        \"backgroundColor\": \"#a06f5f\",\n        \"color\": \"#ffbfb4\",\n        \"fontWeight\": \"bold\"\n      },\n      {\n        \"backgroundColor\": \"#a06f5f\",\n        \"color\": \"#FFF\"\n      }\n    ],\n    \"(.*?__if__)([^!]+?)(__.*?)\\\\n\": [\n      {\n        \"backgroundColor\": \"#a06f5f\",\n        \"color\": \"#FFF\"\n      },\n      {\n        \"backgroundColor\": \"#a06f5f\",\n        \"color\": \"#c7ffa4\",\n        \"fontWeight\": \"bold\"\n      },\n      {\n        \"backgroundColor\": \"#a06f5f\",\n        \"color\": \"#FFF\"\n      }\n    ],\n    \"((?:\\\\/\\\\/|#) __if__)([^!]+?)(__)\": [\n      {\n        \"backgroundColor\": \"#808080\",\n        \"color\": \"#FFF\"\n      },\n      {\n        \"backgroundColor\": \"#808080\",\n        \"color\": \"#c7ffa4\",\n        \"fontWeight\": \"bold\"\n      },\n      {\n        \"backgroundColor\": \"#808080\",\n        \"color\": \"#FFF\"\n      }\n    ],\n    \"((?:\\\\/\\\\/|#) __if__)(!.+?)(__)\": [\n      {\n        \"backgroundColor\": \"#808080\",\n        \"color\": \"#FFF\"\n      },\n      {\n        \"backgroundColor\": \"#808080\",\n        \"color\": \"#ffbfb4\",\n        \"fontWeight\": \"bold\"\n      },\n      {\n        \"backgroundColor\": \"#808080\",\n        \"color\": \"#FFF\"\n      }\n    ],\n    \"((?:\\\\/\\\\/|#) __endif__)\": [\n      {\n        \"backgroundColor\": \"#808080\",\n        \"color\": \"#FFF\"\n      }\n    ],\n    \"(__replace__)(.+?)(__)\": [\n      {\n        \"backgroundColor\": \"#5F9EA0\",\n        \"color\": \"#FFF\"\n      },\n      {\n        \"backgroundColor\": \"#5F9EA0\",\n        \"color\": \"#FFF\",\n        \"fontWeight\": \"bold\"\n      },\n      {\n        \"backgroundColor\": \"#5F9EA0\",\n        \"color\": \"#FFF\"\n      }\n    ]\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamlab%2Fkettle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbamlab%2Fkettle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbamlab%2Fkettle/lists"}