Closed martinpesava closed 6 years ago
By default 'plugins_paths'
'plugins_paths' => [
base_path() . '/resources/smarty/plugins',
],
https://github.com/ytake/Laravel.Smarty/blob/master/src/config/ytake-laravel-smarty.php#L56
or ServiceProviders example) register filter
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class ApplicationServiceProvider extends ServiceProvider
{
public function boot(): void
{
$this->registerFilters();
}
public function registerFilters(): void
{
$smarty = $this->app['view']->getSmarty();
$smarty->registerFilter('post', [$this, 'add_header_comment']);
}
public function add_header_comment($tpl_source, $smarty)
{
return "<?php echo \"<!-- Created by Smarty From ServiceProvider! -->\n\"; ?>\n".$tpl_source;
}
}
Thanks, it worked.
Hello, is it possible and how to write my own plugin, which won't be in the default smarty plugin directory inside vendor folder, but samewhere inside app folder? Thanks