{"id":21651670,"url":"https://github.com/hoytech/templar","last_synced_at":"2025-10-07T02:15:54.583Z","repository":{"id":171526009,"uuid":"641542529","full_name":"hoytech/templar","owner":"hoytech","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-21T06:16:33.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-13T01:46:50.436Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Perl","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/hoytech.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-05-16T17:31:51.000Z","updated_at":"2025-02-02T19:34:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"02c516dc-aea2-4e08-a6c7-1f0c9e9fa6a7","html_url":"https://github.com/hoytech/templar","commit_stats":null,"previous_names":["hoytech/templar"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hoytech/templar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2Ftemplar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2Ftemplar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2Ftemplar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2Ftemplar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoytech","download_url":"https://codeload.github.com/hoytech/templar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoytech%2Ftemplar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278708004,"owners_count":26031932,"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-10-07T02:00:06.786Z","response_time":59,"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":[],"created_at":"2024-11-25T07:49:09.704Z","updated_at":"2025-10-07T02:15:54.578Z","avatar_url":"https://github.com/hoytech.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Templar\n\nC++ HTML template compiler\n\nThis is a perl script that compiles a directory of `.tmpl` files into a C++17 header file. This header file can then be used in a C++ application to emit HTML.\n\nInspired by [hypertextcpp](https://github.com/kamchatka-volcano/hypertextcpp) with a few differences:\n\n* Automatic HTML escaping to protect against XSS bugs\n  * The normal `$(...)` replacement will perform escaping, ie convert `\u003c` into `\u0026lt;` etc\n  * If the replacement is inside an HTML attribute, single/double quotes are also escaped\n  * When using sub-templates, no escaping is performed. For example, to use the template in `items/myItem.tmpl` as a sub-template, this will do the right thing: `$(items::myItem(ctx.item))`\n  * If you want to *not* do the escaping, use the form `$!(...)` (be careful!)\n* React-style empty tags `\u003c\u003e...\u003c/\u003e` for grouping items in conditions or loops without requiring enclosing tag\n* Minification: Non-semantic whitespace in the template HTML is (mostly) removed at compile-time\n* Single header output, as opposed to header per template\n  * Converts directory structure of templates into namespaces\n  * All templates are forward-declared so any template can call into another sub-template\n* Instead of iostreams, this module concatenates strings\n  * Rather than outputing independent C++ statements for each tag, templar coalesces adjacent literals into a single statement\n  * I don't know if the above changes improve or degrade performance. There are arguments both ways, and I have not benchmarked anything\n* Single-stage build process (no need to compile the template compiler)\n* Output headers start with `#pragma once`\n* Parameter struct is named `ctx` not `cfg`\n* Less tested, missing some features\n  * Currently unimplemented: sections (haven't needed it yet), procedures (use sub-templates), shared library renderer (no plans to do this)\n  * A bit more limited in what types `$()` can handle. It has to be a string/string_view, or have an `std::to_string()` overload\n\n## Dependencies\n\nTemplate depends on `Regexp::Grammars` and `Template` perl modules. On debian/ubuntu systems you can install these packages:\n\n    sudo apt install -y libregexp-grammars-perl libtemplate-perl\n\n## Usage\n\nSee the setup in the `ex` directory. To compile:\n\n    ./templar.pl tmpls/ tmpl mytmpls.h\n\n* `tmpls/` is a directory that contains `.tmpl` files (all sub-directories are also searched)\n* `tmpl` is the C++ namespace for your templates\n* `mytmpls.h` is the output header file\n\n## Copyright\n\n(C) 2023 Doug Hoyte\n\nMIT license\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoytech%2Ftemplar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoytech%2Ftemplar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoytech%2Ftemplar/lists"}