{"id":18870416,"url":"https://github.com/sebastiansulinski/blade","last_synced_at":"2025-04-14T15:21:31.405Z","repository":{"id":62541631,"uuid":"62418198","full_name":"sebastiansulinski/blade","owner":"sebastiansulinski","description":"Blade templates outside of Laravel.","archived":false,"fork":false,"pushed_at":"2020-02-29T08:52:19.000Z","size":13,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-14T20:58:03.050Z","etag":null,"topics":["blade-directives","blade-template","blade-template-engine","php-template-engine"],"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/sebastiansulinski.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":"2016-07-01T20:29:34.000Z","updated_at":"2022-06-16T07:55:28.000Z","dependencies_parsed_at":"2022-11-02T15:45:27.544Z","dependency_job_id":null,"html_url":"https://github.com/sebastiansulinski/blade","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/sebastiansulinski%2Fblade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastiansulinski%2Fblade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastiansulinski%2Fblade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastiansulinski%2Fblade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebastiansulinski","download_url":"https://codeload.github.com/sebastiansulinski/blade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223635084,"owners_count":17177075,"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":["blade-directives","blade-template","blade-template-engine","php-template-engine"],"created_at":"2024-11-08T05:20:06.397Z","updated_at":"2024-11-08T05:20:07.009Z","avatar_url":"https://github.com/sebastiansulinski.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Blade\nPackage to allow you use blade templates outside of Laravel.\n\n[![Build Status](https://travis-ci.org/sebastiansulinski/blade.svg?branch=master)](https://travis-ci.org/sebastiansulinski/blade)\n\n### Usage instructions\n\nBlade constructor takes 4 arguments, 2 of which are optional:\n\n```php\n$viewPaths: // either a string or array of paths where your views will be fetched from\n$cachePath: // string representing the path to the cache directory (to store cached version of the views)\nContainer $app = null: // instance of the Illuminate\\Container\\Container (optional)\nDispatcher $events = null: // instance of the Illuminate\\Events\\Dispatcher (optional)\nFilesystem $events = null: // instance of the Illuminate\\Events\\Filesystem (optional)\n```\n\nWith new instance of the Blade class you can call the `view()` methods the same way as from within Laravel using [view()](https://laravel.com/docs/master/views) helper.\n\n```php\n$blade = new Blade(\n    realpath(__DIR__ . '/../resources/views'),\n    realpath(__DIR__ . '/../resources/cache')\n);\n```\n\n#### Passing variables\n```php\n$user = User::find(1);\n\n$blade-\u003eview('index', compact('user'));\n\n$blade-\u003eview('index', ['user' =\u003e $user]);\n\n$blade-\u003eview('index')-\u003ewith('user', $user);\n```\n\n#### Determining if a view exists\n```php\n$blade-\u003eview()-\u003eexists('test');\n```\n\n#### Sharing data with all views\n```php\n$blade-\u003eshare('user', $user);\n```\n\n#### View composers\n```php\n$blade-\u003eview()-\u003ecomposer('dashboard', function(View $view) {\n\n    $user = new stdClass;\n    $user-\u003ename = 'Martin';\n\n    $view-\u003ewith('user', $user);\n\n});\n\n$blade-\u003eview('dashboard');\n// has instance of $user available\n```\n\n#### Blade vew template\n\nUse blade view templates the same way as with [Laravel](https://laravel.com/docs/master/blade)\n\n```php\n// index.blade.php\n\n@extends('template.layout')\n\n@section('content')\n\n\u003ch1\u003eHallo {{ $user-\u003ename }}\u003c/h1\u003e\n\n@endsection\n```\n\n#### Example\n\n```php\n// /public/index.php\n\n$blade = new Blade(\n    realpath(__DIR__ . '/../resources/views'),\n    realpath(__DIR__ . '/../resources/cache')\n);\n\n$user = User::find(1);\n\necho $blade-\u003eview('pages.index', compact('user'));\n\n\n// /resources/views/template/layout.blade.php\n\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003eTitle\u003c/title\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\n\u003cdiv class=\"row\"\u003e\n\n    \u003cdiv class=\"column\"\u003e\n\n        @yield('content')\n\n    \u003c/div\u003e\n\n\u003c/div\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n\n\n// /resources/views/pages/index.blade.php\n\n@extends('template.layout')\n\n@section('content')\n\n\u003ch1\u003eHallo {{ $user-\u003ename }}\u003c/h1\u003e\n\n@endsection\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastiansulinski%2Fblade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastiansulinski%2Fblade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastiansulinski%2Fblade/lists"}