{"id":18425230,"url":"https://github.com/htmlburger/wpemerge-twig","last_synced_at":"2025-04-07T15:33:41.189Z","repository":{"id":48176024,"uuid":"112620907","full_name":"htmlburger/wpemerge-twig","owner":"htmlburger","description":"Enables the use of Twig templates in WPEmerge.","archived":false,"fork":false,"pushed_at":"2021-03-14T18:31:13.000Z","size":50,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-26T17:09:37.286Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/htmlburger.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":"2017-11-30T14:27:10.000Z","updated_at":"2023-09-13T16:20:15.000Z","dependencies_parsed_at":"2022-09-16T13:22:09.296Z","dependency_job_id":null,"html_url":"https://github.com/htmlburger/wpemerge-twig","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htmlburger%2Fwpemerge-twig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htmlburger%2Fwpemerge-twig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htmlburger%2Fwpemerge-twig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htmlburger%2Fwpemerge-twig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htmlburger","download_url":"https://codeload.github.com/htmlburger/wpemerge-twig/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247680210,"owners_count":20978218,"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-06T05:03:04.969Z","updated_at":"2025-04-07T15:33:39.273Z","avatar_url":"https://github.com/htmlburger.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WP Emerge Twig\n\nEnables the use of Twig views in [WP Emerge](https://github.com/htmlburger/wpemerge).\n\n## Quickstart\n\n1. Run `composer require htmlburger/wpemerge-twig` in your theme directory\n2. Add `\\WPEmergeTwig\\View\\ServiceProvider` to your array of providers when booting WPEmerge:\n    ```php\n    \\App::make()-\u003ebootstrap( [\n        'providers' =\u003e [\n            \\WPEmergeTwig\\View\\ServiceProvider::class,\n        ],\n    ] );\n    ```\n\n## Options\n\nDefault options:\n```php\n[\n    // Automatically replace the default view engine for WP Emerge.\n    'replace_default_engine' =\u003e true,\n\n    // Pass .php views to the default view engine.\n    // replace_default_engine must be true for this to take effect.\n    'proxy_php_views' =\u003e true,\n\n    // One or more directories to search for views.\n    // Defaults to the main ['views'] key of the configuration.\n    'views' =\u003e [get_stylesheet_directory(), get_template_directory()],\n\n    // Options passed directly to Twig.\n    'options' =\u003e [\n        // 'cache' defaults to the main ['cache']['path'] key of the configuration.\n        'cache' =\u003e 'wp-content/uploads/wpemerge/cache/twig',\n    ],\n]\n```\n\nYou can change these options by specifying a `twig` key in your WP Emerge config array:\n```php\n\\App::make()-\u003ebootstrap( [\n    // ... other WP Emerge options\n    'twig' =\u003e [\n        // ... other WP Emerge Twig options\n        'options' =\u003e [\n            // ... other Twig options\n            'cache' =\u003e false,\n        ],\n    ],\n] );\n```\n\nMore information on what Twig options are supported is available on [https://twig.symfony.com/doc/2.x/api.html](https://twig.symfony.com/doc/2.x/api.html).\n\n## Extending Twig\n\nYou can use the following to extend twig with a custom filter, for example:\n```php\n$myfilter = new Twig_Filter( 'myfilter', function( $string ) {\n    return strtoupper( $string );\n} );\n\n// \\App::resolve() used for brevity's sake - use a Service Provider instead.\n$twig = \\App::resolve( WPEMERGETWIG_VIEW_TWIG_VIEW_ENGINE_KEY );\n$twig-\u003eenvironment()-\u003eaddFilter( $myfilter );\n```\nWith this, you now have your very own custom Twig filter:\n```twig\n{{ 'hello world!' | myfilter }}\n```\n\nMore information on how you can extend Twig is available on [https://twig.symfony.com/doc/2.x/advanced.html#creating-extensions](https://twig.symfony.com/doc/2.x/advanced.html#creating-extensions).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtmlburger%2Fwpemerge-twig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtmlburger%2Fwpemerge-twig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtmlburger%2Fwpemerge-twig/lists"}