{"id":18771016,"url":"https://github.com/rareloop/primer-template-engine-twig","last_synced_at":"2025-12-12T03:30:15.245Z","repository":{"id":62533337,"uuid":"41862229","full_name":"Rareloop/primer-template-engine-twig","owner":"Rareloop","description":null,"archived":false,"fork":false,"pushed_at":"2018-08-03T08:37:34.000Z","size":38,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-30T02:08:37.627Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Rareloop.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}},"created_at":"2015-09-03T13:49:00.000Z","updated_at":"2018-08-03T08:37:35.000Z","dependencies_parsed_at":"2022-11-02T16:01:00.368Z","dependency_job_id":null,"html_url":"https://github.com/Rareloop/primer-template-engine-twig","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rareloop%2Fprimer-template-engine-twig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rareloop%2Fprimer-template-engine-twig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rareloop%2Fprimer-template-engine-twig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rareloop%2Fprimer-template-engine-twig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rareloop","download_url":"https://codeload.github.com/Rareloop/primer-template-engine-twig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239678103,"owners_count":19679202,"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":[],"created_at":"2024-11-07T19:22:51.256Z","updated_at":"2025-12-12T03:30:13.133Z","avatar_url":"https://github.com/Rareloop.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Twig Template Engine for Primer\n\n![CI](https://travis-ci.org/Rareloop/primer-template-engine-twig.svg)\n\nA template engine for [Primer](http://github.com/rareloop/primer) that uses Twig rather than the deafult (Handlebars).\n\n## Installation\n\n1. In the `composer.json` in your Primer install, replace:\n\n    ````json\n    \"rareloop/primer-template-engine-handlebars\": \"dev-master\"\n    ````\n\n    with:\n\n    ````json\n    \"rareloop/primer-template-engine-twig\": \"1.0.*\"\n    ````\n\n2. Run `composer update`.\n\n3. Modify your `bootstrap/start.php` file and change the `Primer::start` call to include the `templateClass` e.g.\n    \n    ````php\n    $primer = Primer::start(array(\n        'basePath' =\u003e __DIR__.'/..', \n        'templateClass' =\u003e Rareloop\\Primer\\TemplateEngine\\Twig\\Template::class,\n    ));\n    ````\n\n4. Replace all `.hbs` files in your patterns and views with `.twig' files. If you don't want to do this by hand you can download the base Primer files in Twig format from [this repo](https://github.com/Rareloop/primer-patterns-twig).\n\n## Usage\n\n### Including patterns within one another\n\nAny pattern can be included within another by using the standard `include` syntax, e.g.\n\n````twig\n\u003cdiv class=\"sub-pattern\"\u003e\n    {% include 'elements/forms/input' %}\n\u003c/div\u003e\n````\n\nMore information on using `{% include %}` and manipulating the passed in context can be found on the [Twig website](http://twig.sensiolabs.org/doc/tags/include.html).\n\n### Extending Templates\nBy default, Primer will wrap all page Templates with a common View (`views/template.twig`). When using `{% extends %}` this wrapping is sometimes undesirable, in such circumstances you can disable this behaviour in a couple of ways.\n\n1. On a per page Template basis. Add the following to the Templates `data.json` file:\n\n    ```\n    {\n        \"primer\": {\n            \"view\": \"custom-view\"\n        }\n    }\n    ```\n2. Site wide. Add `wrapTemplate: false` to the `Primer::start` call in `bootstrap/start.php`, e.g.\n    ```php\n    $primer = Primer::start([\n        'basePath' =\u003e __DIR__.'/..',\n    \n        'templateClass' =\u003e TwigTemplateEngine::class,\n        'wrapTemplate' =\u003e false,\n    ]);\n    ```\n\n\n### Twig Template Cache\n\nBy default Primer uses a directory called `cache` inside the project root for cache files. To change this to somewhere else you can set an alternative when you start Primer in `bootstrap/start.php`, e.g.\n\n````php\n$primer = Primer::start(array(\n    'basePath' =\u003e __DIR__.'/..', \n    'cachePath' =\u003e 'absolute/path/to/cache/dir',\n    'templateClass' =\u003e Rareloop\\Primer\\TemplateEngine\\Twig\\Template::class,\n));\n\n````\n\n### Custom Events\n\nMost of the Primer events are still available, this package adds a few engine specific events too:\n\n- ### Twig Engine Initialisation\n    \n    Called when the Twig engine is created. Useful for registering custom helpers with the Twig engine.\n\n    ````php\n    Event::listen('twig.init', function ($twig) {\n\n    });\n    ````\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frareloop%2Fprimer-template-engine-twig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frareloop%2Fprimer-template-engine-twig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frareloop%2Fprimer-template-engine-twig/lists"}