{"id":18864322,"url":"https://github.com/devtronic/twig-compose","last_synced_at":"2026-04-27T11:31:14.967Z","repository":{"id":56967122,"uuid":"117885469","full_name":"devtronic/twig-compose","owner":"devtronic","description":"A twig extension to compose templates from multiple child templates.","archived":false,"fork":false,"pushed_at":"2019-10-21T04:17:00.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-30T14:16:45.407Z","etag":null,"topics":["multi-extend","php","symfony","twig","twig-extension"],"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/devtronic.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}},"created_at":"2018-01-17T19:53:53.000Z","updated_at":"2019-10-21T04:17:01.000Z","dependencies_parsed_at":"2022-08-21T10:21:00.500Z","dependency_job_id":null,"html_url":"https://github.com/devtronic/twig-compose","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/devtronic/twig-compose","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Ftwig-compose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Ftwig-compose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Ftwig-compose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Ftwig-compose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devtronic","download_url":"https://codeload.github.com/devtronic/twig-compose/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devtronic%2Ftwig-compose/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32335295,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"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":["multi-extend","php","symfony","twig","twig-extension"],"created_at":"2024-11-08T04:40:52.684Z","updated_at":"2026-04-27T11:31:14.950Z","avatar_url":"https://github.com/devtronic.png","language":"PHP","funding_links":["https://github.com/sponsors/devtronic"],"categories":[],"sub_categories":[],"readme":"# ✨ Twig Compose Environment ✨\nA twig extension to compose templates from multiple child templates.\n\n## ❓ What does this?\nFor example you've a base template and N child template which can modify the base Template.\nIf the templates are fixed, there is no problem you can extend from each other.\nIs the number of templates dynamic you can't use extend. In that case you can use this bundle.\nSimply call the compose method, pass a base template and a array of sub-templates... and wibbly wobbly you've a template\nwhich contains every content of every child template 🌠\n\n## 📦 Installation\n```bash\n$ composer require devtronic/twig-compose\n```\n\n## ❤ Sponsors\nNo sponsors at the moment. [Become a sponsor](https://github.com/sponsors/devtronic)\n\n## 🛠 Usage\nFor details take a look in the tests directory\n### ➡ With a your existing Twig_Environment\n```php\n\u003c?php\n\nuse Devtronic\\TwigCompose\\ComposeEnvironment;\n\n/** @var $twig Twig_Environment */\n$twig-\u003eaddExtension(new Devtronic\\TwigCompose\\ComposeExtension());\n$template = ComposeEnvironment::composeStatic($twig, 'base.html.twig', ['pluginA.html.twig', 'pluginB.html.twig']);\n\necho $template-\u003erender([]);\n```\n\n### ➡ With the ComposeEnvironment\n```php\n\u003c?php\n\nuse Devtronic\\TwigCompose\\ComposeEnvironment;\n\n$loader = new \\Twig_Loader_Filesystem(''); // or whatever\n$twig = new ComposeEnvironment($loader); // instead of Twig_Environment\n\n$template = $twig-\u003ecompose('base.html.twig', ['pluginA.html.twig', 'pluginB.html.twig']);\n\necho $template-\u003erender([]);\n```\n\n### ➡ Auto composing templates (Experimental \u0026 ComposeEnvironment only)\n```php\n\u003c?php\n\nuse Devtronic\\TwigCompose\\ComposeEnvironment;\n\n$loader = new \\Twig_Loader_Filesystem('/res/main-theme');\n$twig = new ComposeEnvironment($loader);\n$loader-\u003eaddPath('/res/theme1', 'Theme1');\n$loader-\u003eaddPath('/res/theme2', 'Theme2');\n\n// If autocompose is enabled, all registered paths will be checked.\n// If a file with the the same name (e.g. base.html.twig) exists,\n// it will be loaded \u0026 composed with the `base.html.twig` inside the main-theme folder\n$twig-\u003esetAutoCompose(true); \n$template = $twig-\u003eload('base.html.twig');\n\necho $template-\u003erender([]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtronic%2Ftwig-compose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevtronic%2Ftwig-compose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevtronic%2Ftwig-compose/lists"}