定制 smorken/string2blade 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

smorken/string2blade

最新稳定版本:v10.3.0

Composer 安装命令:

composer require smorken/string2blade

包简介

String to Blade compiler for Laravel

README 文档

README

Provides the ability for Laravel to handle raw strings as blade templates.

Per the norm, you are responsible for what is in the template string! User provided input is probably a terrible idea.

The 'string' will be cached using a sha1 of the value so modifying the string value should result in laravel creating a new cached file.

License

This software is open-sourced software licensed under the MIT license

The Laravel framework is open-sourced software licensed under the MIT license

Installation

It should register itself automatically. If not, add to your config/app.php:

...
'providers' => [
        Smorken\String2Blade\ServiceProvider::class,
        Smorken\String2Blade\MailerServiceProvider::class,
...

String2Blade Use

  • Contract
// create view factory from DI
$view = App::make(\Smorken\String2Blade\Contracts\View\Factory::class);
$view->make('hello {{ $world }}!', ['world' => 'Earth']);
  • Facade
use Smorken\String2Blade\Facades\String2Blade;

String2Blade::make('hello {{ $world }}')->with('world', 'Earth');

Mailable Use

  • Blade template string
use Smorken\String2Blade\Mail\Mailable;

class TestMailable extends Mailable
{

    public function build(): void
    {
        $this->to('fiz@example.com')
             ->from('buz@example.com')
             ->subject('Test Subject')
             ->view('hello {{ $world }}')
             ->with(
                 [
                     'world' => 'earth',
                 ]
             );
    }
}
  • Markdown template string
use Smorken\String2Blade\Mail\Mailable;

class TestMarkdownMailable extends Mailable
{

    public function build(): void
    {
        $this->to('fiz@example.com')
             ->from('buz@example.com')
             ->subject('Test Subject')
             ->markdown($this->getMarkdown())
             ->with(
                 [
                     'world' => 'earth',
                 ]
             );
    }

    protected function getMarkdown(): string
    {
        return <<<STR
@component('mail::message')
# Hello

Your world is {{ \$world }}
@endcomponent
STR;
    }
}

统计信息

  • 总下载量: 1.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-11-23