-
Notifications
You must be signed in to change notification settings - Fork 120
Template calling methods
Jorge Castro edited this page Dec 3, 2020
·
2 revisions
Tag | Note |
---|---|
@inject('metrics', 'App\Services\MetricsService') | Used for insert a Laravel Service |
@inject('metric', 'App\Services\MetricsService')
<div>
Monthly Revenue: {{ $metric->monthlyRevenue() }}.
</div>
By default, BladeOne creates a new instance of the class 'variable name'
inside 'namespace'
with a parameter-less constructor.
To override the logic used to resolve injected classes, pass a function to setInjectResolver
.
Example with Symphony Dependency Injection.
$containerBuilder = new ContainerBuilder();
$loader = new XmlFileLoader($containerBuilder, new FileLocator(__DIR__));
$loader->load('services.xml');
$blade->setInjectResolver(function ($namespace, $variableName) use ($loader) {
return $loader->get($namespace);
});
It works exactly like the command "use" of PHP.
@use(\namespace1\namespace2)
Copyright Jorge Castro Castillo
- BladeOne Manual
- Template tags (views)
- Custom control
- Methods of the class
- Injecting logic before the view (composer)
- Extending the class
- Using BladeOne with YAF Yet Another Framework
- Differences between Blade and BladeOne
- Comparision with Twig (May-2020)
- Changelog
- Changes between 2.x and 3.0 and TODO
- Code Protection (Sourceguardian and similars)