{"id":18582094,"url":"https://github.com/lorefnon/hbs-dedent-helper","last_synced_at":"2026-03-07T21:31:13.993Z","repository":{"id":37990570,"uuid":"199772549","full_name":"lorefnon/hbs-dedent-helper","owner":"lorefnon","description":"Minimal handlebars helper to un-indent blocks","archived":false,"fork":false,"pushed_at":"2023-10-18T04:10:09.000Z","size":461,"stargazers_count":1,"open_issues_count":4,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-18T15:57:50.308Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/lorefnon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"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":"2019-07-31T03:39:16.000Z","updated_at":"2022-06-12T19:43:34.000Z","dependencies_parsed_at":"2024-06-21T07:12:38.590Z","dependency_job_id":"eb28d528-cdde-4eae-a03f-fa3f7f199ae1","html_url":"https://github.com/lorefnon/hbs-dedent-helper","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/lorefnon/hbs-dedent-helper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fhbs-dedent-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fhbs-dedent-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fhbs-dedent-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fhbs-dedent-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lorefnon","download_url":"https://codeload.github.com/lorefnon/hbs-dedent-helper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lorefnon%2Fhbs-dedent-helper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30231602,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T19:01:10.287Z","status":"ssl_error","status_checked_at":"2026-03-07T18:59:58.103Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-07T00:09:14.025Z","updated_at":"2026-03-07T21:31:13.959Z","avatar_url":"https://github.com/lorefnon.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Handlebars dedent helper\n\nA set of simple handlebars helpers to help with indentation\n\nVery often, when using block helpers our code would end up nested more than it should be. Which can be problematic for code-generators:\n\n```\nif (foo) {\n    {{#each items}}\n        console.log('{{.}}')\n    {{/each}}\n}\n```\n\ngenerates something like: \n\n```js\nif (foo) {\n        console.log('a');\n        console.log('b');\n}\n```\n\nThis is visually unappealing. In addition, for indentation sensitve languages this can break the code.\n\nTo solve this we provide following helpers: \n\n1. `dedent` helper: \n\n(Dedents a block of code by one level)\n\n```\nif (foo) {\n    {{#each items}}\n        {{#dedent}}\n        console.log('{{.}}')\n        {{/dedent}}\n    {{/each}}\n}\n```\n\nOne level defaults to 4 spaces. But this is configurable through setLevelSize \u0026 setLevelChar: \n\n```js\nimport {setLevelSize} from \"hbs-dedent-helper\";\n\n// Configure dedent helper to use 1 tab\nsetLevelSize(1);\nsetLevelChar('\\\\t');\n```\n\n2. `dedent-by` helper provides more control: \n\n```\nif (foo) {\n    {{#dedent-by 2 \"level\"}}\n        {{#each items}}\n            console.log('{{.}}')\n        {{/each}}\n    {{/dedent-by}}\n}\n```\n\nWe can also explicitly use tabs or spaces: \n\n```\nif (foo) {\n    {{#dedent-by 8 \"spaces\"}}\n        {{#each items}}\n            console.log('{{.}}')\n        {{/each}}\n    {{/dedent-by}}\n}\n```\n\n```\nif (foo) {\n    {{#dedent-by 2 \"tabs\"}}\n        {{#each items}}\n            console.log('{{.}}')\n        {{/each}}\n    {{/dedent-by}}\n}\n```\n\n3. `base-indent` helper:\n\n(Changes the minimum indentation of all lines in the contained block, while retaining relative indentation)\n\n```\nif (foo) {\n    {{#base-indent 1 \"level\"}}\n        {{#each items}}\n            console.log('{{.}}')\n        {{/each}}\n    {{/base-indent}}\n}\n```\n\n```\nif (foo) {\n    console.log(1)\n}\n```\n\nThis is particularly useful when including other templates in a base template.\n\n4. `trim-trailing-whitespace` helper:\n\n(Removes all trailing whitespace in generated output)\n\n# Installation\n\n```\nnpm install --save handlebars hbs-dedent-helper\n```\n\n# Registration\n\n```\nimport {register} from \"hbs-dedent-helper\";\n\nregister();\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florefnon%2Fhbs-dedent-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Florefnon%2Fhbs-dedent-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Florefnon%2Fhbs-dedent-helper/lists"}