{"id":15283952,"url":"https://gitlab.com/renestalder/eleventy-plugin-twig-php","last_synced_at":"2025-05-07T03:24:29.723Z","repository":{"id":50507268,"uuid":"37124594","full_name":"renestalder/eleventy-plugin-twig-php","owner":"renestalder","description":"Plugin for the 11ty (Eleventy) static site generator to render template with the PHP version of Twig","archived":false,"fork":false,"pushed_at":null,"size":null,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":null,"default_branch":"main","last_synced_at":"2025-04-20T05:04:34.262Z","etag":null,"topics":["11ty","11ty-plugin","eleventy","eleventy-plugin","twig"],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":null,"metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-06-17T20:29:36.554Z","updated_at":"2022-09-13T14:35:19.943Z","dependencies_parsed_at":"2022-08-24T03:20:56.620Z","dependency_job_id":null,"html_url":"https://gitlab.com/renestalder/eleventy-plugin-twig-php","commit_stats":null,"previous_names":[],"tags_count":4,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/renestalder%2Feleventy-plugin-twig-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/renestalder%2Feleventy-plugin-twig-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/renestalder%2Feleventy-plugin-twig-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories/renestalder%2Feleventy-plugin-twig-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/owners/renestalder","download_url":"https://gitlab.com/renestalder/eleventy-plugin-twig-php/-/archive/main/eleventy-plugin-twig-php-main.zip","host":{"name":"gitlab.com","url":"https://gitlab.com","kind":"gitlab","repositories_count":4518895,"owners_count":6976,"icon_url":"https://github.com/gitlab.png","version":null,"created_at":"2022-05-30T11:31:42.605Z","updated_at":"2024-07-18T11:24:13.055Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/gitlab.com/owners"}},"keywords":["11ty","11ty-plugin","eleventy","eleventy-plugin","twig"],"created_at":"2024-09-30T14:48:24.646Z","updated_at":"2025-05-07T03:24:29.704Z","avatar_url":null,"language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# 11ty (Eleventy) Twig PHP Plugin\n\n\u003e Under development\n\nPlugin to add support for rendering Twig templates in Eleventy with the\noriginal PHP Twig engine. Supports all features of the official Twig\nspecification, [version 2.x](https://twig.symfony.com/doc/2.x/).\n**Requires PHP to be installed in the build environment**.\n\n## Use cases\n\n- You want build websites with 11ty and want to use the full feature set\n  of Twig according to the supported version of this plugin.\n- You want to use 11ty for building component libraries and\n  documentations that are consumed by PHP projects (therefore need\n  feature parity).\n- You want to compile Twig outside of PHP projects.\n\n## Alternatives\n\n- **[Eleventy Plugin Twig](https://github.com/factorial-io/eleventy-plugin-twig)**:\n  11ty Twig plugin using TwigJS under the hood. TwigJS doesn't have full\n  feature parity with the original PHP engine. But the this plugin comes\n  with handy additions on top for building websites, like image\n  resizing, and might be a better, more lightweight approach to using\n  Twig with 11ty if you have an environment without PHP support. Or\n  simply want an out-of-the-box toolset for building websites with Twig.\n\n## Getting started\n\n### Requirements\n\n- **PHP and composer needs to be available in your build environment**.\n  This also means, these projects can only build in CI/CD environments\n  that have PHP installed.\n\n### Installation\n\nInstall the plugin via your preferred Node package manager.\n\n_Example for npm:_\n\n```\nnpm install --save-dev eleventy-plugin-twig-php\n```\n\n### Usage\n\nAdd the plugin to your Eleventy configuration, e.g. `.eleventy.js`:\n\n```js\nconst twig = require('eleventy-plugin-twig-php');\n\nmodule.exports = function (eleventyConfig) {\n  eleventyConfig.addPlugin(twig, options);\n\n  // Other configuration...\n};\n```\n\n#### Options\n\n##### `twig.namespaces`\n\nSet up Twig namespaces. Example:\n\n```js\nconst twig = require('eleventy-plugin-twig-php');\n\nmodule.exports = function (eleventyConfig) {\n  eleventyConfig.addPlugin(twig, {\n    twig: {\n      namespaces: {\n        macros: 'path/to/macro/folder',\n      },\n    },\n  });\n\n  // Other configuration...\n};\n```\n\n```twig\n{# Imports path/to/macro/folder/my-macro.twig #}\n{% from '@macros/my-macro' import my_macro %}\n```\n\n## Development\n\n```sh\nnpm ci\nnpm run test\n```\n\n### Docker\n\nThe project comes with a `docker-compose.yml`. To make usage easier, it\nalso includes a `Makefile` to run node commands directly in the Docker\ncontainer:\n\n```sh\nmake install\nmake test\n```\n\n## Acknowledgements\n\n- The fantastic work of knapsack-cloud/basalt on the\n  [PHP Twig renderer for node](https://github.com/knapsack-cloud/twig-renderer)\n- [patternlab](https://patternlab.io/) for being a great toolset for\n  years, that has shown me how the PHP version of Twig can be cleverly\n  used together with Node.\n\n## Contributing\n\nSee `CONTRIBUTING.md` for a few guidelines.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/gitlab.com%2Frenestalder%2Feleventy-plugin-twig-php","html_url":"https://awesome.ecosyste.ms/projects/gitlab.com%2Frenestalder%2Feleventy-plugin-twig-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/gitlab.com%2Frenestalder%2Feleventy-plugin-twig-php/lists"}