{"id":13792203,"url":"https://github.com/quasilyte/KTemplate","last_synced_at":"2025-05-12T14:31:42.937Z","repository":{"id":58363215,"uuid":"524073795","full_name":"quasilyte/KTemplate","owner":"quasilyte","description":"KTemplate is a simple text template engine for PHP and KPHP","archived":false,"fork":false,"pushed_at":"2024-04-03T16:21:43.000Z","size":626,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-23T19:52:10.003Z","etag":null,"topics":["composer-package","kphp","ktemplate","library","php","template","template-engine","twig"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/quasilyte.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2022-08-12T12:09:35.000Z","updated_at":"2022-12-15T00:33:03.000Z","dependencies_parsed_at":"2024-08-03T22:06:22.373Z","dependency_job_id":"f2bd26bf-5217-44d6-83ab-38c409b6f51c","html_url":"https://github.com/quasilyte/KTemplate","commit_stats":{"total_commits":177,"total_committers":1,"mean_commits":177.0,"dds":0.0,"last_synced_commit":"32551cfa6320e9053db4100dbe2348f84ffe0ad3"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2FKTemplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2FKTemplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2FKTemplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quasilyte%2FKTemplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quasilyte","download_url":"https://codeload.github.com/quasilyte/KTemplate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253754967,"owners_count":21958934,"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":["composer-package","kphp","ktemplate","library","php","template","template-engine","twig"],"created_at":"2024-08-03T22:01:09.443Z","updated_at":"2025-05-12T14:31:42.543Z","avatar_url":"https://github.com/quasilyte.png","language":"PHP","funding_links":[],"categories":["Table of Contents"],"sub_categories":["Libraries"],"readme":"![](_docs/logo.png)\n\n## Overview\n\n[KTemplate](https://github.com/quasilyte/KTemplate) is a simple text template engine for PHP and [KPHP](https://github.com/VKCOM/kphp).\n\nKTemplate uses a syntax similar to the Twig, Django and Jinja template languages.\n\nYou can try it [online](https://quasilyte.tech/ktemplate/)!\n\n**Features:**\n\n* **Cross-language support**: works for both PHP and KPHP\n* **Security**: no eval or dynamic PHP code generation/loading is used\n* **Compile-time checks**: many errors are caught during template compilation\n* **Zero-copy data binding**: efficient and flexible data provider model\n* **Performance**: templates are compiled to optimized bytecode\n\n## Quick Start\n\n```bash\n$ composer require quasilyte/ktemplate\n```\n\n```php\n\u003c?php\n\nrequire_once __DIR__ . '/vendor/autoload.php';\n\nuse KTemplate\\Context;\nuse KTemplate\\Engine;\nuse KTemplate\\ArrayLoader;\nuse KTemplate\\ArrayDataProvider;\n\n$loader = new ArrayLoader([\n    'main' =\u003e '{{ title }}',\n]);\n$engine = new Engine(new Context(), $loader);\n$data = new ArrayDataProvider(['title' =\u003e 'Example']);\n$result = $engine-\u003erender('main', $data);\nvar_dump($result); // =\u003e \"Example\"\n```\n\nRun with PHP:\n\n```bash\n$ php -f example.php\nstring(7) \"Example\"\n```\n\nRun with KPHP:\n\n```bash\n# 1. Compile\n$ kphp --composer-root $(pwd) --mode cli example.php\n# 2. Execute\n$ ./kphp_out/cli\nstring(7) \"Example\"\n```\n\n## Documentation\n\n* [Template language overview](_docs/template_language.md)\n* [KTemplate idioms](_docs/ktemplate_idioms.md)\n* [Differences from Twig](_docs/differences_from_twig.md)\n* [KTemplate PHP API](_docs/ktemplate_php_api.md)\n* [KTemplate architecture](_docs/ktemplate_architecture.md)\n\n## Rationale\n\nNone of the template engines for PHP can be used with KPHP.\n\nKTemplate is a solution that works in both languages.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2FKTemplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquasilyte%2FKTemplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquasilyte%2FKTemplate/lists"}