{"id":18909020,"url":"https://github.com/chdh/minitemplator-js","last_synced_at":"2026-03-06T21:30:23.230Z","repository":{"id":57298077,"uuid":"345226726","full_name":"chdh/minitemplator-js","owner":"chdh","description":"A compact template engine for HTML.","archived":false,"fork":false,"pushed_at":"2022-04-21T02:59:52.000Z","size":24,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-31T23:33:30.606Z","etag":null,"topics":["template-engine","template-engine-html","template-engine-js"],"latest_commit_sha":null,"homepage":"https://www.source-code.biz/MiniTemplator","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/chdh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-07T00:41:00.000Z","updated_at":"2022-04-22T19:19:18.000Z","dependencies_parsed_at":"2022-09-26T18:41:56.490Z","dependency_job_id":null,"html_url":"https://github.com/chdh/minitemplator-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fminitemplator-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fminitemplator-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fminitemplator-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chdh%2Fminitemplator-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chdh","download_url":"https://codeload.github.com/chdh/minitemplator-js/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239896454,"owners_count":19715021,"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":["template-engine","template-engine-html","template-engine-js"],"created_at":"2024-11-08T09:30:12.707Z","updated_at":"2026-03-06T21:30:23.134Z","avatar_url":"https://github.com/chdh.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MiniTemplator - JavaScript Version\n\nMiniTemplator is a compact, optimized template engine primarily used for generating HTML output.\n\n## Template syntax\n\nVariables:\n\u003cpre\u003e\u003ccode\u003e${\u003ci\u003evariableName\u003c/i\u003e}\n\u003c/code\u003e\u003c/pre\u003e\n\nBlocks:\n\u003cpre\u003e\u003ccode\u003e\u0026lt;!-- $beginBlock \u003ci\u003eblockName\u003c/i\u003e --\u003e\n  \u003ci\u003e... block content ...\u003c/i\u003e\n\u0026lt;!-- $endBlock \u003ci\u003eblockName\u003c/i\u003e --\u003e\n\u003c/code\u003e\u003c/pre\u003e\n\nConditional statements:\n\u003cpre\u003e\u003ccode\u003e\u0026lt;!-- $if \u003ci\u003econdExpr\u003c/i\u003e --\u003e\n  ...\n\u0026lt;!-- $elseIf \u003ci\u003econdExpr\u003c/i\u003e --\u003e\n  ...\n\u0026lt;!-- $else --\u003e\n  ...\n\u0026lt;!-- $endIf --\u003e\n\u003c/code\u003e\u003c/pre\u003e\n\nInclude a subtemplate:\n\u003cpre\u003e\u003ccode\u003e\u0026lt;!-- $include \u003ci\u003efileName\u003c/i\u003e --\u003e\n\u003c/code\u003e\u003c/pre\u003e\n\n## Principles\n\n- Blocks can be nested.\n- Subtemplates can include other subtemplates.\n- Conditions are JavaScript expressions that use condition variables.\n\n### Phases\n\nThere are two phases when using MiniTemplator templates.\n\n#### Phase 1: Loading, parsing and caching\n\nWhen a template is parsed, condition expressions are evaluated, conditional statements are resolved and subtemplates are included.\nA template is normally loaded and parsed only once and then used many times.\nA parsed template can be cached in memory for later re-use.\n\n#### Phase 2: Output document buildup\n\nIn the second phase, template variables are set and blocks are added.\nWhen the document buildup is complete, everything is merged into a HTML string, which is the output of the template engine.\n\n### Variables\n\nThere are two kinds of variables.\n\n#### Condition variables\n\nCondition variables are used in `$if` and `$elseIf` statements.\n\n- Condition variables are used at the time a template is loaded and parsed.\n- For each set of condition variable values, a separate parsed template object is cached.\n\n#### Template variables\n\nTemplate variables are used to place content into the template.\n\n- Template variables are used when applying a parsed template to generate output.\n- When a template variable is used within a block, it must be set before the `addBlock()` method for the block is called.\n- The values `undefined` and `null` are converted into an empty string.\n\n### Short form for conditional statements\n\nWhen the `shortFormEnabled` option is set to `true`, the following alternative form can be used for conditional statements:\n\n\u003cpre\u003e\u003ccode\u003e\u0026lt;$? \u003ci\u003econdExpr\u003c/i\u003e\u003e\n  ... \u003ci\u003econtent for \"if\" case\u003c/\u003e ...\n\u0026lt;$: \u003ci\u003econdExpr\u003c/i\u003e\u003e\n  ... \u003ci\u003econtent for \"elseIf\" case\u003c/i\u003e ...\n\u0026lt;$:\u003e\n  ... \u003ci\u003econtent for \"else\" case\u003c/i\u003e ...\n\u0026lt;$/?\u003e\n\u003c/code\u003e\u003c/pre\u003e\n\nExample:\n\u003cpre\u003e\u003ccode\u003e\u0026lt;$?de\u003e Hallo Welt!\n\u0026lt;$:fr\u003e Bonjour le monde!\n\u0026lt;$:it\u003e Ciao mondo!\n\u0026lt;$:  \u003e Hello world!\n\u0026lt;$/?\u003e\n\u003c/code\u003e\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchdh%2Fminitemplator-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchdh%2Fminitemplator-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchdh%2Fminitemplator-js/lists"}