{"id":18721037,"url":"https://github.com/mauricius/wireframerendererblade","last_synced_at":"2025-10-26T20:35:53.629Z","repository":{"id":66196114,"uuid":"271635477","full_name":"mauricius/WireframeRendererBlade","owner":"mauricius","description":"Laravel Blade renderer for the Wireframe output framework","archived":false,"fork":false,"pushed_at":"2024-12-22T10:24:14.000Z","size":37,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-26T09:01:47.816Z","etag":null,"topics":["laravel","processwire","processwire-modules"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mauricius.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-06-11T19:56:23.000Z","updated_at":"2024-12-22T10:23:43.000Z","dependencies_parsed_at":"2023-03-18T03:45:43.289Z","dependency_job_id":null,"html_url":"https://github.com/mauricius/WireframeRendererBlade","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2FWireframeRendererBlade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2FWireframeRendererBlade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2FWireframeRendererBlade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mauricius%2FWireframeRendererBlade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mauricius","download_url":"https://codeload.github.com/mauricius/WireframeRendererBlade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248579339,"owners_count":21127800,"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":["laravel","processwire","processwire-modules"],"created_at":"2024-11-07T13:33:21.591Z","updated_at":"2025-10-26T20:35:48.608Z","avatar_url":"https://github.com/mauricius.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## WireframeRendererBlade\n\nBlade renderer for the ProcessWire [Wireframe](https://wireframe-framework.com/) output framework.\n\n---\n\nThis module is an optional renderer add-on for the Wireframe output framework, adding support for the [Laravel Blade](https://laravel.com/docs/5.8/blade) templating engine.\n\n## Basic usage\n\nFirst of all, you need to install both Wireframe and WireframeRenderBlade.\n\nThen you have to install the dependencies of WireframeRenderBlade by running\n\n```bash\ncomposer install\n```\n\nin the module folder.\n\nFinally, you can set up Wireframe (as instructed at https://wireframe-framework.com/getting-started/). Once that's done, you can open the bootstrap file (`wireframe.php`) and instruct Wireframe to use the Blade renderer:\n\n```php\n// during Wireframe init (this is the preferred way):\n$wireframe-\u003einit([\n    'renderer' =\u003e ['WireframeRendererBlade', [\n        // optional settings array\n    ]],\n]);\n\n// ... or after init (this incurs a slight overhead):\n$wireframe-\u003esetRenderer('WireframeRendererBlade', [\n    // optional settings array\n]);\n```\n\n### Settings\n\nYou can provide your values for the `views` and `cache` paths. Default values are outlined below:\n\n```php\n[\n    'views' =\u003e '/site/templates/views',\n    'cache' =\u003e '/site/assets/cache/WireframeRendererBlade'\n]\n```\n\n## Blade templates\n\nOnce you've told Wireframe to use the Blade renderer, by default it will attempt to render all your views, layouts, partials and components using Blade. File extension for Blade files is `.blade.php`.\n\nNote that if a Blade file can't be found, Wireframe will automatically fall back to native (`.php`) file. This is intended to ease migrating from PHP to Blade, and also makes it possible for Blade and PHP view files to co-exist.\n\n### Layouts\n\nBlade allows you to extend a parent layout using the Blade `@extends` directive, to specify which layout the child view should \"inherit\". By default all layouts are referenced from the `views` folder\n\n```bladehtml\n@extends('layout')\n```\n\n```\n.\n|-- views\n|   |-- layout.blade.php\n|   └-- child.blade.php\n```\n\nOtherwise, you can keep the Wireframe concept of layout and use a Blade file from the `layouts` folder, by prefixing the layout with the `layout::` namespace\n\n```bladehtml\n@extends('layout::layout')\n```\n\n```\n.\n|-- layout\n|   └-- layout.blade.php\n|-- views\n|   └-- child.blade.php\n```\n\n### Includes (partials)\n\nThe same concept is valid for sub-views. You can include a Blade file from another view using the `@include` directive. By defaut it will pick up partials from the `views` folder. If you prefer to use a file from the Wireframe `partials` directory you can prefix the partial name with the `partial::` namespace.\n\n### Extending Blade\n\nIf you want to extend Blade (e.g. add a new directive), you can access the Blade Environment by hooking into `WireframeRendererBlade::initBlade`:\n\n#### Adding a Custom Directive\n\n```php\n// site/ready.php\n$wire-\u003eaddHookAfter('WireframeRendererBlade::initBlade', function(HookEvent $event) {\n    $event-\u003ereturn-\u003edirective('hello', function ($expression) {\n        return \"\u003c?php echo 'Hello ' . {$expression}; ?\u003e\";\n    });\n});\n\n```\n\n```bladehtml\n@hello('World')\n```\n\n#### Adding a Custom If Directive\n\n```php\n// site/ready.php\n$wire-\u003eaddHookAfter('WireframeRendererBlade::initBlade', function(HookEvent $event) use ($user) {\n    $event-\u003ereturn-\u003eif('superuser', function () use ($user) {\n        return $user-\u003eisLoggedIn() and $user-\u003eisSuperuser();\n    });\n});\n\n```\n\n```bladehtml\n@superuser\n    \u003ch2\u003eHello\u003c/h2\u003e\n@else\n    \u003cp\u003eYou don't have access here\u003c/p\u003e\n@endsuperuser\n```\n\n#### Adding a directive to cache partial HTML with [Markup Cache Module](https://modules.processwire.com/modules/markup-cache/)\n\n```php\n// site/ready.php\n$wire-\u003eaddHookAfter('WireframeRendererBlade::initBlade', function(HookEvent $event) use ($wire) {\n     $event-\u003ereturn-\u003edirective('cache', function ($expression) use ($wire) {\n        $args = array_map(function ($item) {\n            return trim($item);\n        }, explode(',', $expression));\n\n        $key = substr($args[0], 1, -1);\n        $duration = $args[1] ?? (24 * 60 * 60); // 24 hours\n\n        return implode('', [\n            \"\u003c?php ob_start(); ?\u003e\",\n            '\u003c?php if (! $__partial = $modules-\u003eget(\"MarkupCache\")-\u003eget(\"' . $key . '\",' . $duration . ')) : ?\u003e',\n        ]);\n    });\n\n    $event-\u003ereturn-\u003edirective('endcache', function () {\n        return implode('', [\n            '\u003c?php endif; ?\u003e',\n            '\u003c?php if (! $__partial): ?\u003e',\n            '\u003c?php $__partial = ob_get_clean(); ?\u003e',\n            '\u003c?php $modules-\u003eget(\"MarkupCache\")-\u003esave($__partial); ?\u003e',\n            '\u003c?php else : ?\u003e',\n            '\u003c?php ob_end_clean(); ?\u003e',\n            '\u003c?php endif; ?\u003e',\n            '\u003c?php echo $__partial; ?\u003e',\n        ]);\n    });\n});\n```\n\n```bladehtml\n@cache('my-cache-key', 3600)\n    {{-- heavy stuff here --}}\n@endcache\n```\n\n#### Adding a directive to cache an included file with [Markup Cache Module](https://modules.processwire.com/modules/markup-cache/)\n\n```php\n// site/ready.php\n$wire-\u003eaddHookAfter('WireframeRendererBlade::initBlade', function(HookEvent $event) use ($wire) {\n     $event-\u003ereturn-\u003edirective('cacheInclude', function ($expression) use ($wire) {\n        $args = array_map(function ($item) {\n            return trim($item);\n        }, explode(',', $expression));\n\n        $key = substr($args[0], 1, -1);\n        $duration = $args[1] ?? (24 * 60 * 60); // 24 hours\n\n        return implode('', [\n            '\u003c?php if (! $__partial = $modules-\u003eget(\"MarkupCache\")-\u003eget(\"' . $key . '\",' . $duration . ')) : ?\u003e',\n            '\u003c?php $__partial = $__env-\u003emake(\"' . $key . '\", \\Illuminate\\Support\\Arr::except(get_defined_vars(), [\"__data\", \"__path\"]))-\u003erender(); ?\u003e',\n            '\u003c?php $modules-\u003eget(\"MarkupCache\")-\u003esave($__partial); ?\u003e',\n            '\u003c?php endif; ?\u003e',\n            '\u003c?php echo $__partial; ?\u003e'\n        ]);\n    });\n});\n```\n\n```bladehtml\n@cacheInclude('my-partial', 3600)\n```\n\nYou can also access the [underlying Blade class](https://github.com/jenssegers/blade) from the `wireframe.php` file:\n\n```php\n$blade = $wireframe-\u003eview-\u003egetRenderer()-\u003egetBladeInstance();\n```\n\n### Localization\n\n[ProcessWire translation functions](https://processwire.com/docs/multi-language-support/code-i18n/) are provided as helpers so you can use `__()` and `_n()` directly in the templates, keeping ProcessWire ability to detect strings that need translation. However you will have to manually override the [textdomain](https://processwire.com/docs/multi-language-support/code-i18n/#using-textdomains) to use the path of the uncompile Blade file, otherwise ProcessWire will not be able to match your translations.\n\nHowever this is easier as it sounds. Just add this code to your `wireframe.php` file\n\n```php\n/**\n * Convert template path into valid textdomain\n * e.g. from /site/templates/views/mypage.blade.php\n * into site--templates--views--mypage-blade-php\n * @param  string $path\n * @return string\n */\nfunction getViewTextDomain($path) {\n    $config = wire('config');\n\n    $input = str_replace('.', '-', str_replace($config-\u003epaths-\u003eroot, '', $path));\n\n    $re = '/\\/+/m';\n\n    return preg_replace($re, '--', $input);\n}\n\n$wireframe-\u003eview-\u003egetRenderer()-\u003egetBladeInstance()-\u003ecomposer('*', function($view)\n{\n    $view-\u003ewith('textdomain', Utils::getViewTextDomain($view-\u003egetPath()));\n});\n```\n\nFinally you can use the `$textdomain` variable wherever you need to translate strings\n\n```bladehtml\n{{ __(\"Translate me\", $textdomain) }}\n```\n\n### Laravel Mix\n\nIn case you're using [Laravel Mix](https://laravel-mix.com/), `WireframeRendererBlade` provides a `mix` function to reference frontend assets.\n\n### Gotchas\n\nSome Blade directives don't work in the ProcessWire context. A few examples are `@inject`, `@can` and `@cannot`.\n\n## License\n\n[MPL](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauricius%2Fwireframerendererblade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmauricius%2Fwireframerendererblade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmauricius%2Fwireframerendererblade/lists"}