{"id":22147545,"url":"https://github.com/myerscode/templex","last_synced_at":"2026-02-09T07:34:16.934Z","repository":{"id":45436859,"uuid":"427614568","full_name":"myerscode/templex","owner":"myerscode","description":"A lightweight, regex based template rendering engine for PHP","archived":false,"fork":false,"pushed_at":"2025-08-15T22:13:11.000Z","size":66,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-20T02:20:42.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/myerscode.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":"2021-11-13T08:55:18.000Z","updated_at":"2025-08-15T21:59:52.000Z","dependencies_parsed_at":"2025-04-10T13:47:03.078Z","dependency_job_id":"bc85fb2d-2c92-43fb-ab03-391fc87316e4","html_url":"https://github.com/myerscode/templex","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/myerscode/templex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Ftemplex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Ftemplex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Ftemplex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Ftemplex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/myerscode","download_url":"https://codeload.github.com/myerscode/templex/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/myerscode%2Ftemplex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29258759,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T04:11:57.159Z","status":"ssl_error","status_checked_at":"2026-02-09T04:11:56.117Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":[],"created_at":"2024-12-01T23:18:20.642Z","updated_at":"2026-02-09T07:34:16.920Z","avatar_url":"https://github.com/myerscode.png","language":"PHP","readme":"# Templex\n\u003e A lightweight, regex based template rendering engine for PHP\n\n[![Latest Stable Version](https://poser.pugx.org/myerscode/templex/v/stable)](https://packagist.org/packages/myerscode/templex)\n[![Total Downloads](https://poser.pugx.org/myerscode/templex/downloads)](https://packagist.org/packages/myerscode/templex)\n[![License](https://poser.pugx.org/myerscode/templex/license)](https://packagist.org/packages/myerscode/templex)\n![Tests](https://github.com/myerscode/templex/actions/workflows/tests.yml/badge.svg?branch=main)\n[![codecov](https://codecov.io/gh/myerscode/templex/graph/badge.svg?token=YR0YHVERNV)](https://codecov.io/gh/myerscode/templex)\n\n## Why this package is helpful?\n\nThis package will allow you to define stubs and then hydrate the template using PHP variables. \nAs the engine uses RegEx it does not rely on using `eval` or including and running the code as PHP. \n\nThis means that you are able to simply generate _*new*_ PHP (or any type of text content filled files for that matter) you need.\n\n## Install\n\nYou can install this package via composer:\n``` bash\ncomposer require myerscode/templex\n```\n\n## Usage\n```php \n$templateDirectory = __DIR__ . '/Resources/Templates/;\n$templateExtentions = 'stub';\n$templex = new Templex($templateDirectory, $templateExtentions);\n\necho $templex-\u003erender('index');\n```\n\n### Template Directory\n\n## Templates\n\nTemplates can be any form of text based files. By default, Templex will look for files with `.stub` or `.template` file extensions.\n\nTemplex uses `\u003c{` and `}\u003e` as opening and closing anchor tags to find and process `Slots`, which can be used to generate \ndynamic views from placeholders and logic.\n\n\n## Slots\n\nSlots are the \"_magic_\" of Templex. They are the isolated functionality that perform replacement and hydrating actions \non a template to create the final rendered output.\n\nThe default included slots are:\n\n* IncludeSlot - Includes another templates content\n* ControlSlot - Process flow based logic, such as foreach, if statements\n* VariableSlot - Replaces single placeholders\n\n## Includes\n\nTo include another template, in order to create reusable stubs you can simply include it by its template name.\n\n```text \n\u003c{ include partials.header }\u003e\n```\n\n## Conditions\nTemplex can process nested slots, so having nested control conditions are handled in the order they are found.\n\nConditions can be variables, numbers, booleans or literal strings and can the usual comparison evaluators.\n```text\n\u003c{ if( $value === 'foobar' ) }\u003e\n...\n\u003c{ if( $value \u003e 7 ) }\u003e\n...\n\u003c{ if( $value == true ) }\u003e\n...\n\u003c{ if( $value != false ) }\u003e\n```\n\nExamples\n```text\n\u003c{ if( $value === $condition ) }\u003e\n \u003cp\u003eThat value was true!\u003c/p\u003e\n\u003c{ endif }\u003e\n\n\u003c{ if( $value === 'foobar' ) }\u003e\n \u003cp\u003eThat value was true!\u003c/p\u003e\n\u003c{ else }\u003e\n \u003cp\u003eThat value was false!\u003c/p\u003e\n\u003c{ endif }\u003e\n```\n\n## Loops\nLoops will take an array variable to create multiple iterations in your template.\n\nExamples\n```text\n\u003cul class=\"row\"\u003e\n    \u003c{ foreach( $users as $user ) }\u003e\n        \u003cli\u003e\u003c{ $user }\u003e\u003c/li\u003e\n    \u003c{ endforeach }\u003e\n\u003c/ul\u003e\n```\n\n## Variables\nVariables are replaced matching anchors are found. They can are passed in at rendering, or created via other slots such as Loops.\n\nExamples\n```text\nHi \u003c{ $name }\u003e!\n```\n\n## Issues and Contributing\n\nWe are very happy to receive pull requests to add functionality or fixes.\n\nBug reports and feature requests can be submitted on the [Github Issue Tracker](https://github.com/myerscode/config/issues).\n\nPlease read the Myerscode [contributing](https://github.com/myerscode/docs/blob/main/CONTRIBUTING.md) guide for information on our Code of Conduct.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Ftemplex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmyerscode%2Ftemplex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmyerscode%2Ftemplex/lists"}