clickfwd / yoyo-blade-app Goto Github PK
View Code? Open in Web Editor NEWYoyo app using Blade templating engine
Home Page: https://getyoyo.dev
Yoyo app using Blade templating engine
Home Page: https://getyoyo.dev
Hello,
As I amtrying to use Illuminate\View
separately from Laravel, I am now using the solution from app/bootloader.php
, and on a separate page without any additional logic it works great. Here's the code:
<?php
require_once 'vendor/autoload.php';
use Clickfwd\Yoyo\Blade\Application;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Contracts\View\Factory as ViewFactory;
use Jenssegers\Blade\Blade;
$app = Application::getInstance();
$app->bind(ApplicationContract::class, Application::class);
$app->alias('view', ViewFactory::class);
$blade = new Blade([__DIR__ . '/views'], __DIR__ . '/compiled', $app);
$blade->compiler()->components([
'components.alert' => 'alert'
]);
$templateData = [
'title' => 'Title',
'text' => 'This is my text!'
];
echo $blade->render('page', $templateData);
But when I try putting it in a separate class I am getting Fatal error: Uncaught Error: Call to undefined method Illuminate\View\Compilers\BladeCompiler::components()
:
...
use Clickfwd\Yoyo\Blade\Application;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Contracts\View\Factory as ViewFactory;
use Jenssegers\Blade\Blade as JenssegersBlade;
class Blade
{
private JenssegersBlade $blade;
public function __construct()
{
$app = Application::getInstance();
$app->bind(ApplicationContract::class, Application::class);
$app->alias('view', ViewFactory::class);
$this->blade = new JenssegersBlade(
[get_template_directory() . '/views'],
get_template_directory() . '/compiled',
$app
);
// Custom anonymous components
$this->blade->compiler()->components([
'components.media-image' => 'media-image'
]);
}
}
When I comment out $this->blade->compiler()->components
part - everything works fine (except for the anonymous component).
Please help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.