astroshippers/laravel-minified-blade

此包提供 `.min.blade.php` 文件扩展名

v1.0.1 2022-06-16 00:53 UTC

README

Laravel Minified Blade

此包提供 .min.blade.php 文件扩展名。

只需将 .min 添加到您的 .blade.php 文件中,模板就会被压缩!⚡

安装

composer require astroshippers/laravel-minified-blade

用法

让我们用这个文件作为一个例子。

<div>
    @if($age > 13)
        <p>
            Welcome to your new account!
        </p>
    @else
        <b>
            Sorry, access denied.
        </b>
    @endif
</div>

通常情况下,不使用此包时,它将被编译成这样

<div>
    <?php if($age > 13): ?>
        <p>
            Welcome to your new account!
        </p>
    <?php else: ?>
        <b>
            Sorry, access denied.
        </b>
    <?php endif; ?>
</div>
<?php /**PATH /home/asdf/code/notionmailer/resources/views/test.blade.php ENDPATH**/ ?>

但是,如果您添加此包并在文件扩展名中使用 .min,您将得到以下结果

<div><?php if($age> 13): ?><p> Welcome to your new account! </p><?php else: ?><b> Sorry, access denied. </b><?php endif; ?></div><?php /**PATH /home/asdf/code/notionmailer/resources/views/test.min.blade.php ENDPATH**/ ?>

有什么用例?

为什么不直接使用指令,如 @minified@endminified

指令在模板渲染后执行,可能会添加不希望的行为,例如动态内容间距被压缩。