{"id":33232209,"url":"https://github.com/sempare/sempare-delphi-template-engine","last_synced_at":"2026-01-14T13:03:28.077Z","repository":{"id":46683065,"uuid":"229803245","full_name":"sempare/sempare-delphi-template-engine","owner":"sempare","description":"Sempare Template (scripting) Engine for Delphi allows for flexible dynamic text generation. It can be used for generating email, html, reports, source code, xml, configuration, etc.","archived":false,"fork":false,"pushed_at":"2025-05-08T19:42:42.000Z","size":8589,"stargazers_count":165,"open_issues_count":7,"forks_count":22,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-12-03T12:34:28.471Z","etag":null,"topics":["delphi","delphi-library","delphinuspackage","pascal-programming","scripting","template-engine"],"latest_commit_sha":null,"homepage":"","language":"Pascal","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sempare.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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,"zenodo":null},"funding":{"buy_me_a_coffee":"sempare","github":["sempare","darnocian"]}},"created_at":"2019-12-23T18:24:43.000Z","updated_at":"2025-11-19T11:42:14.000Z","dependencies_parsed_at":"2023-02-09T03:01:07.762Z","dependency_job_id":"e2e3cb3e-88c4-4406-ae53-e577bb8269ab","html_url":"https://github.com/sempare/sempare-delphi-template-engine","commit_stats":null,"previous_names":["sempare/sempare.template"],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/sempare/sempare-delphi-template-engine","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sempare%2Fsempare-delphi-template-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sempare%2Fsempare-delphi-template-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sempare%2Fsempare-delphi-template-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sempare%2Fsempare-delphi-template-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sempare","download_url":"https://codeload.github.com/sempare/sempare-delphi-template-engine/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sempare%2Fsempare-delphi-template-engine/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28420816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["delphi","delphi-library","delphinuspackage","pascal-programming","scripting","template-engine"],"created_at":"2025-11-16T18:00:21.983Z","updated_at":"2026-01-14T13:03:28.062Z","avatar_url":"https://github.com/sempare.png","language":"Pascal","funding_links":["https://buymeacoffee.com/sempare","https://github.com/sponsors/sempare","https://github.com/sponsors/darnocian"],"categories":["Template"],"sub_categories":[],"readme":"![delphi compatibility](https://img.shields.io/badge/delphi%20compatability-XE%204%20or%20newer-brightgreen)\r\n![platform compatibility](https://img.shields.io/badge/platform-Android32%20%7C%20Android64%20%7C%20Linux64%20%7C%20macOS64%20%7C%20Win32%20%7C%20Win64-lightgrey)\r\n\r\n# ![](./images/sempare-logo-45px.png) Sempare Template Engine\r\n\r\nCopyright (c) 2019-2025 [Sempare Limited](http://www.sempare.ltd)\r\n\r\nContact: \u003cinfo@sempare.ltd\u003e\r\n\r\nLicense: [Apache v2.0](https://www.apache.org/licenses/LICENSE-2.0) or [Sempare Limited Commercial License](./docs/commercial.license.md)\r\n\r\nOpen Source: https://github.com/sempare/sempare-delphi-template-engine\r\n\r\n*Questionaire*: https://docs.google.com/forms/d/e/1FAIpQLScioIiDxvsWK01fMFqYr9aJ6KhCGeiw4UaU_esGuztEE7vYwA/viewform\r\n\r\n\u003ca name=\"Introduction\"\u003e\u003ch2\u003eIntroduction\u003c/h3\u003e\u003c/a\u003e\r\n\r\nTemplate engines are used often in technology where text needs to be customised by substituting variables with values from a data source. Examples where this may take place:\r\n- web sites using template engines (for server side scripting)\r\n- code generation\r\n- mail merge\r\n- notification messages\r\n\r\nThe Sempare Template Engine is a small templating (scripting) engine for [Delphi](https://www.embarcadero.com/products/delphi) (Object Pascal) that allows for templates to be created easily and efficiently by providing a simple and easy to use API.\r\n\r\nExample usage:\r\n```\r\nprogram Example;\r\nuses\r\n    Sempare.Template;\r\ntype\r\n    TInformation = record\r\n        name: string;\r\n        favourite_sport : string;\r\n        count : integer;\r\n    end;\r\nbegin\r\n    var tpl := Template.Parse(\r\n       'My name is \u003c% name %\u003e.'#13#10 +\r\n       'My favourite sport is \u003c% favourite_sport %\u003e.'#13#10 +\r\n       'Counting... \u003c% for i := 1 to count %\u003e\u003c% i %\u003e\u003c% betweenitems %\u003e, \u003c% end %\u003e' +\r\n       'Counting... \u003c% for i := 1 to count ; print(i) ; betweenitems ; print(', '); onbegin; print('[ '); onend; print('] '); end %\u003e'\r\n    );\r\n    var info : TInformation;\r\n    info.name := 'conrad';\r\n    info.favourite_sport := 'ultimate';\r\n    info.count := 3;\r\n    writeln(Template.Eval(tpl, info));\r\nend.\r\n```\r\n\r\nThe project allows for almost any type to be dereferenced within the template script.\r\n\r\nIn the example above, you can see that the '\u003c%' start and '%\u003e' end the scripting statement respectively. Within a scripting statement, you can reference variables, assign variables, use conditions, for and while loops, and include other templates.\r\n\r\n**NOTE** In examples in this documentation I may use the latest Delphi syntax, e.g. inline variable declarations. This is not backward compatible as they were introduced in Delphi 10.2 and are used to shorten the code/examples being illustrated in the documentation. The codebase will attempt to be as backward compatible as possible.\r\n\r\n\u003ca name=\"CallToAction\"\u003e\u003ch2\u003eCall to action\u003c/h3\u003e\u003c/a\u003e\r\n\r\nPlease 'star' the project on github.\r\n\r\n![](./images/sempare-template-engine-start-cta.png)\r\n\r\n\u003ca name=\"Articles\"\u003e\u003ch2\u003eArticles\u003c/h3\u003e\u003c/a\u003e\r\n\r\n- [Accessing data from the Sempare Template Engine for Delphi](https://dev.to/sempare/accessing-data-from-the-sempare-template-engine-for-delphi-5dg8)\r\n- [Accessing a FireDAC dataset from the Sempare Template Engine for Delphi](https://dev.to/sempare/accessing-a-firedac-dataset-from-the-sempare-template-engine-for-delphi-4j3g)\r\n- [Using the Sempare Template Engine for Delphi](https://dev.to/sempare/using-the-sempare-template-engine-for-delphi-29nn)\r\n- [Configuring the Sempare Template Engine for Delphi](https://dev.to/sempare/configuring-the-sempare-template-engine-for-delphi-27pn)\r\n- [The Sempare Template Engine for Delphi: Advanced Template Registry Features](https://dev.to/sempare/the-sempare-template-engine-advanced-template-registry-features-29o9)\r\n- [Creating helper functions for the Sempare Template Engine](https://dev.to/sempare/creating-helper-functions-for-the-sempare-template-engine-3nla)\r\n- [Functional templates with the Sempare Template Engine for Delphi](https://dev.to/sempare/functional-templates-with-the-sempare-template-engine-for-delphi-2p3d)\r\n- [Creating layouts using the Sempare Template Engine for Delphi](https://dev.to/sempare/creating-layouts-using-the-sempare-template-engine-3ah8)\r\n- [Using loops in the Sempare Template Engine for Delphi](https://dev.to/sempare/using-loops-in-the-sempare-template-engine-for-delphi-417m)\r\n- [Eliminating whitespace in Sempare Template Engine for Delphi templates](https://dev.to/sempare/eliminating-whitespace-in-sempare-template-engine-for-delphi-templates-3e0o)\r\n- [Introducing the Sempare Template Engine Playground Wizard for the Delphi RAD Studio IDE](https://dev.to/sempare/introducing-the-sempare-template-engine-playground-wizard-for-the-delphi-rad-studio-ide-1jmn)\r\n\r\n## Contents\r\n- [Introduction](#Introduction)\r\n- [Call To Action](#CallToAction)\r\n- [Quickstart](#Quickstart)\r\n- [Features](#Features)\r\n- [Objectives](#Objectives)\r\n- [Requirements](#Requirements)\r\n- [Installation](#Installation)\r\n    - [GetIt](#GetIt)\r\n    - [Boss](#Boss)\r\n    - [Delphinus](#DelphinusSupport)\r\n    - [Manual Install](#ManualInstall)\r\n- [Feedback](#Feedback)\r\n- Template Language\r\n  - [Statements](./docs/statements.md)\r\n  - [Expressions](./docs/expressions.md)\r\n  - [Builtin functions](./docs/builtin-functions.md)\r\n  - [Builtin variables](./docs/builtin-variables.md)\r\n  - [Comments](./docs/comments.md)\r\n- [Template Registry](./docs/template-registry.md)\r\n- Customisation\r\n  - [Custom functions](./docs/custom-functions.md)\r\n  - [Configuration](./docs/configuration.md)\r\n- [Components](./docs/components.md)\r\n- [Tricks](./docs/tricks.md)\r\n- [Template Patterns](./docs/template-patterns.md)\r\n- [Whitespace Removal](./docs/whitespace-removal.md)\r\n- [Internals](./docs/internals.md)\r\n- [Restrictions/Limitations/Known Bugs](./docs/restrictions.md)\r\n- [License](#License)\r\n\r\n\u003ca name=\"Quickstart\"\u003e\u003ch2\u003eQuickstart\u003c/h3\u003e\u003c/a\u003e\r\n\r\nThere are a few ways to get started quickly.\r\n\r\n- Look at the examples on how to do server side scripting using some popular web frameworks:\r\n   - [WebBroker](https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Creating_WebBroker_Applications) [Demo](https://github.com/sempare/sempare-delphi-template-engine/tree/main/demo/WebBrokerStandalone)\r\n   - [Horse](https://github.com/hashload/horse) [Demo](https://github.com/sempare/sempare-delphi-template-engine-horse-demo)\r\n   - [Synopse mORMot1](https://synopse.info) [Demo](https://github.com/edwinyzh/simple-sempare-template-engine-mormot1-demo)\r\n   - [DelphiMVCFramework](https://github.com/danieleteti/delphimvcframework) [Demo](https://github.com/danieleteti/delphimvcframework/tree/master/samples/serversideviews_sempare)\r\n\r\n[Try the demo](./demo//SempareTemplatePlayground/README.md) if you want to dive in quick and play with the template engine.\r\n\r\n\u003ca name=\"Features\"\u003e\u003ch2\u003eFeatures\u003c/h3\u003e\u003c/a\u003e\r\n- statements\r\n  - if, elif, else statements\r\n  - for and while statements\r\n  - include statement\r\n  - extends / block statements\r\n  - with statement\r\n  - function/method calls\r\n- expressions\r\n  - simple expression evaluation (logical, numerical and string)\r\n  - variable definition\r\n  - functions and methods calls\r\n  - dereference records, custom managed records, classes, interfaces, arrays, JSON objects, TDataSet descendants and dynamic arrays\r\n  - ternary operator\r\n- safety\r\n  - max run-time protection\r\n- customisation \r\n  - custom script token replacement\r\n  - add custom functions\r\n  - strip recurring spaces and new lines\r\n- lazy template resolution\r\n- parse time evaluation of expressions/statements\r\n- allow use of custom encoding (UTF-8 with BOM, UTF-8 without BOM, ASCII, etc)\r\n- extensibile RTTI interface to easily dereference classes and interfaces (current customisations for ITemplateVariables, TDictionary, TJsonObject)\r\n\r\n\u003ca name=\"Objectives\"\u003e\u003ch2\u003eObjectives\u003c/h3\u003e\u003c/a\u003e\r\n\r\nThe Sempare Template Engine is not intended to be a fully featured general purpose programming language such as PHP where the script itself could be a self contained programming language (but it does have most of the features).\r\n\r\nSempare Template Engine aims to provide just enough functionality to allow you to easily work with the 'view' aspects of a template. Any enhanced functionality required from the scripting environment should be provided by the custom functions written in Object Pascal.\r\n\r\n\u003ca name=\"Requirements\"\u003e\u003ch2\u003eRequirements\u003c/h3\u003e\u003c/a\u003e\r\n\r\nThe template engine works with modern versions of [Delphi](https://www.embarcadero.com/products/delphi). \r\n\r\nTests currently run using the DUnitX TestFramework.\r\n\r\nAn attempt has been made not to use the latest features to ease backward compatability. The following versions have been tested:\r\n\r\n- Delphi XE 4 to XE 8\r\n- Delphi 10.0 Seatle\r\n- Delphi 10.1 Berlin\r\n- Delphi 10.2 Tokyo\r\n- Delphi 10.3.3 Rio\r\n- Delphi 10.4 Sydney\r\n- Delphi 11.0 to 11.3 Alexandria\r\n- Delphi 12 Athens\r\n\r\nThere should be no platform specific restrictions.\r\n\r\nHave a look at Sempare.Template.Compiler.inc. The following defines can be defined if appropriate:\r\n\r\n- SEMPARE_TEMPLATE_NO_INDY - if Indy is not present. This is used to access an html encoder if TNetEncoding is not available.\r\n\r\n\u003ca name=\"Installation\"\u003e\u003ch2\u003eInstallation\u003c/h3\u003e\u003c/a\u003e\r\n\r\n\u003ca name=\"GetIt\"\u003e\u003ch3\u003eGetIt\u003c/h3\u003e\u003c/a\u003e\r\n\r\nThe Sempare Template Engine for Delphi can be installed via the [Embarcadero GetIt manager](https://getitnow.embarcadero.com/?q=sempare\u0026product=rad-studio)\r\n\r\nThis will add the *src* folder to the search path so you can start working immediately.\r\n\r\n\u003ca name=\"Boss\"\u003e\u003ch3\u003eBoss\u003c/h3\u003e\u003c/a\u003e\r\n\r\nThe Sempare Template Engine for Delphi can be installed via the [Boss](https://github.com/hashload/boss/releases) package manager.\r\n\r\nSimply run: \r\n```\r\nboss install sempare/sempare-delphi-template-engine\r\n```\r\n\r\n\u003ca name=\"DelphinusSupport\"\u003e\u003ch3\u003eDelphinus\u003c/h3\u003e\u003c/a\u003e\r\n\r\nThe Sempare Template Engine for Delphi can be installed via the [Delphinus](https://github.com/Memnarch/Delphinus) package manager.\r\n\r\nThis will add the *src* folder to the search path so you can start working immediately.\r\n\r\n\u003ca name=\"ManualInstall\"\u003e\u003ch3\u003eManual Install\u003c/h3\u003e\u003c/a\u003e\r\n\r\nStart by adding the *src* folder to the Delphi search path. Otherwise, there are some projects you can use:\r\n\r\nOpen __Sempare.Template.Engine.Group.groupproj__ which will include:\r\n\r\n- __Sempare.Template.Pkg.dproj__\r\n\r\n  The core template project. (runtime)\r\n     \r\n- __Sempare.Template.Tester.dproj__\r\n\r\n   180+ unit tests\r\n\r\n- __demo\\SempareTemplatePlayground\\Sempare.TemplateEngine.Playground.dproj__\r\n\r\n   The Sempare Template Playground demo which provides a rich experience for testing the various template language features.\r\n   \r\n\u003ca name=\"Feedback\"\u003e\u003ch2\u003eFeedback\u003c/h3\u003e\u003c/a\u003e\r\n\r\nYou can raise issues on [GitHub](https://github.com/sempare/sempare.template) and they will be addressed based on priority.\r\n\r\nMost features have some basic tests in place. If a bug is been discovered, please include a basic test/scenario replicating the issue if possible as this will ease the investigation process.\r\n\r\n\u003ca name=\"Contributions\"\u003e\u003ch2\u003eContributions\u003c/h3\u003e\u003c/a\u003e\r\n\r\nReview [contibution terms and conditions](./docs/CONTRIBUTION.pdf) to contribute to the project.\r\n\r\nPlease followow the following steps when adding a feature or making an update:\r\n- clone the repository\r\n- create a feature branch\r\n- create a pull request to the 'dev' branch\r\n\r\nThe deployment process is based off the dev branch. Once we decide to push a new version, we will merge 'dev' into 'main'.\r\n\r\n\u003ca name=\"License\"\u003e\u003ch2\u003eLicense\u003c/h3\u003e\u003c/a\u003e\r\n\r\nThe Sempare Template Engine is dual-licensed. You may choose to use it under the restrictions of the [Apache v2.0](https://www.apache.org/licenses/LICENSE-2.0) at\r\nno cost to you, or you may license it for use under the [Sempare Limited Commercial License](./docs/commercial.license.md)\r\n\r\nThe dual-licensing scheme allows you to use and test the library under the appropriate license.\r\n\r\nA commercial licence grants you the right to use Sempare Template Engine in your own applications, royalty free, and without any requirement to disclose your source code nor any modifications to\r\nSempare Template Engine or to any other party. A commercial license helps to ensure the project is maintained with continuous integration, patches, etc.\r\n\r\nA support fee of $70 per developer is appreciated.\r\n\r\nThe following payment links allow you to quickly subscribe. Please note that the initial license and support links are seperate.\r\n- [Initial License Fee](https://buy.stripe.com/aEU7t61N88pffQIdQQ)\r\n- [Annual Support License Fee](https://buy.stripe.com/00g8xa4ZkbBr480145)\r\n\r\nThe following payment links are available for site licenses. Please note that the initial license and support links are seperate.\r\n- [Initial Site License Fee](https://buy.stripe.com/eVa00E77s7lbfQIaEG)\r\n- [Annual Support License Fee](https://buy.stripe.com/6oE14I4Zk6h7fQI003)\r\n\r\nPlease send an e-mail to info@sempare.ltd to request an invoice which will contain alternative payment details.\r\n\r\nSupport and enhancement requests submitted by users that pay for support will be prioritised. New developments may incur additional costs depending on time required for implementation.\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsempare%2Fsempare-delphi-template-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsempare%2Fsempare-delphi-template-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsempare%2Fsempare-delphi-template-engine/lists"}