{"id":21819367,"url":"https://github.com/dflydev/dflydev-theme-twig-extension","last_synced_at":"2026-05-04T21:39:56.320Z","repository":{"id":5272496,"uuid":"6451136","full_name":"dflydev/dflydev-theme-twig-extension","owner":"dflydev","description":"Theme Twig Extension","archived":false,"fork":false,"pushed_at":"2013-01-15T04:23:34.000Z","size":128,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T09:19:14.162Z","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/dflydev.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":"2012-10-30T02:48:06.000Z","updated_at":"2017-04-01T10:18:34.000Z","dependencies_parsed_at":"2022-08-21T09:50:48.277Z","dependency_job_id":null,"html_url":"https://github.com/dflydev/dflydev-theme-twig-extension","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-theme-twig-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-theme-twig-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-theme-twig-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dflydev%2Fdflydev-theme-twig-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dflydev","download_url":"https://codeload.github.com/dflydev/dflydev-theme-twig-extension/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244779901,"owners_count":20509234,"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-27T16:18:41.941Z","updated_at":"2026-05-04T21:39:51.293Z","avatar_url":"https://github.com/dflydev.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Theme Twig Extension\n====================\n\nA [Theme][00] extension for [Twig][01].\n\n\nInstallation\n------------\n\nThrough [Composer][00] as [dflydev/theme-twig-extension][01].\n\n\nUsage\n-----\n\nThe following examples use the Symfony Routing implementation of\n`ResourceUrlGeneratorInterface`.\n\n```php\n\u003c?php\nuse Dflydev\\Theme\\ResourceUrlGenerator\\SymfonyRoutingResourceUrlGenerator;\nuse Dflydev\\Twig\\Extension\\Theme\\ThemeTwigExtension;\n\n// Assumes $themeProvider, $pathMapper, $urlGenerator, and $twig\n// are already created and ready to be used.\n\n$resourceUrlGenerator = new SymfonyRoutingResourceUrlGenerator(\n    $themeProvider,\n    $pathMapper,\n    $urlGenerator\n);\n\n$themeTwigExtension = new ThemeTwigExtension(\n    $resourceUrlGenerator\n);\n\n$twig-\u003eaddExtension($themeTwigExtension);\n```\n\nOnce enabled, Theme resources can be referenced by:\n\n    {{ theme_resource('css/main.css') }}\n\nIf `css/main.css` is accessible directly via the Theme instances docroot\n(as determined by the `PathMapperInterface`) then a URL to the public\nresource will be used.\n\nIf `css/main.css` is *not* accessible directly, the `UrlGeneratorInterface`\nimplementation will be used to generate a URL to the embedded Theme\ncontrollers.\n\nAll implementations of `ResourceUrlGeneratorInterface` should follow the\npattern of:\n\n 1. Checking to see if the resource is available publicly and\n    using that if available.\n 2. Generating a fallback URL to expose non-public resources.\n\n\n### Controller Requirements Example (Silex + Symfony Routing)\n\n * **_dflydev_typed_theme_handler**:\n   Expects three params, `type`, `name`, and the `resource`. Name can be\n   changed by calling `setTypedRouteName()`.\n\n   Example:\n\n   ```php\n   \u003c?php\n   $app-\u003eget('/_theme_typed/{type}/{name}/resources/{resource}', function($type, $name, $resource) use ($app)  {\n       // do something to handle the theme request and return the\n       // contents of the theme resource manually.\n   })\n   -\u003eassert('name', '.+')\n   -\u003eassert('resource', '.+')\n   -\u003ebind('_dflydev_typed_theme_handler');\n   ```\n * **_dflydev_theme_handler**:\n   Expects two params, `name` and the `resource`. Name can be changed by calling\n   `setTypedRouteName()`.\n\n   Example:\n\n   ```php\n   \u003c?php\n   $app-\u003eget('/_theme/{name}/resources/{resource}', function($name, $resource) use ($app) {\n       // do something to handle the theme request and return the\n       // contents of the theme resource manually.\n   })\n   -\u003eassert('name', '.+')\n   -\u003eassert('resource', '.+')\n   -\u003ebind('_dflydev_theme_handler');\n   ```\n\nLicense\n-------\n\nMIT, see LICENSE.\n\n\nCommunity\n---------\n\nIf you have questions or want to help out, join us in the\n[#dflydev][#dflydev] channel on irc.freenode.net.\n\n[00]: http://github.com/dflydev/dflydev-theme\n[01]: http://twig.sensiolabs.org/\n[02]: http://getcomposer.org\n[03]: https://packagist.org/packages/dflydev/ant-path-matcher\n\n[#dflydev]: irc://irc.freenode.net/#dflydev\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflydev%2Fdflydev-theme-twig-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdflydev%2Fdflydev-theme-twig-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdflydev%2Fdflydev-theme-twig-extension/lists"}