• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

appstract/laravel-blade-directives: A collection of nice Laravel Blade directive ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

appstract/laravel-blade-directives

开源软件地址(OpenSource Url):

https://github.com/appstract/laravel-blade-directives

开源编程语言(OpenSource Language):

PHP 99.2%

开源软件介绍(OpenSource Introduction):

Laravel Blade Directives

Latest Version on Packagist Total Downloads Software License Build Status

A collection of nice Laravel Blade directives.

Installation

You can install the package via composer:

composer require appstract/laravel-blade-directives

Usage

@istrue

Only show when $variable isset and true.

@istrue($variable)
   This will be echoed
@endistrue

Or when you would like to quickly echo

@istrue($variable, 'This will be echoed')

@isfalse

Same as @istrue but checks for isset and false.

@isfalse($variable)
   This will be echoed
@endisfalse

@isnull

Only show when $variable is null.

@isnull($variable)
   This will be echoed
@endisnull

@isnotnull

Same as @isnull but one shows when $variable is not null.

@isnotnull($variable)
   This will be echoed
@endisnotnull

@dump and @dd

@dump($var)

@dd($var)

@mix

Create a HTML element to your Laravel-Mix css or js.

@mix('/css/app.css')
@mix('/js/app.js')

Output:

<link rel="stylesheet" href="{{ mix('/css/app.css') }}">
<script src="{{ mix('/js/app.js') }}"></script>

@style

Create a <style> element or <link> element with a css path.

@style
    body { background: black }
@endstyle


@style('/css/app.css')

@script

Create a <script> element with or without a js path.

@script
    alert('hello world')
@endscript


@script('/js/app.js')

@inline

Load the contents of a css or js file inline in your view.

@inline('/js/manifest.js')

@pushonce

Same as @push but will include content one time only. Useful for repeatable blocks.

First parameter must follow the syntax stack-name:group-name.

@pushonce('js:foobar')
    <script src="{{ asset('/js/foobar.js') }}"></script>
@endpushonce

Include pushes with standard @stack directive:

@stack('js')

@routeis

Checks if the current route name is equal to the given parameter. You can use a wildcard like blog.post.*.

@routeis('webshop.checkout')
    Do something only on the checkout
@endrouteis

@routeisnot

Checks if the current route name is not equal to the given parameter. You can use a wildcard like blog.post.*

@routeisnot('webshop.checkout')
    Do something only if this is not the checkout
@endrouteisnot

@instanceof

Checks if the first parameter is an instance of the second parameter.

@instanceof($user, 'App\User')
    User is an instance of App\User
@endinstanceof

@typeof

Checks if the parameter is of a certain type.

@typeof($text, 'string')
    Text is a string
@endtypeof

@repeat

Repeat something a specified amount of times.

@repeat(3)
    Iteration #{{ $iteration }}
@endrepeat

@fa, @fas, @far, @fal, @fab, @fad, @mdi, @glyph

Quickly output an icon with Font Awesome, Material Design Icons or Glyphicon.

@fa('address-book', 'optional-extra-class')

// for Font Awesome 5 (solid, regular, light, brand, duotone):
@fas('address-book', 'optional-extra-class')
@far('address-book', 'optional-extra-class')
@fal('address-book', 'optional-extra-class')
@fab('address-book', 'optional-extra-class')
@fad('address-book', 'optional-extra-class')

// for Material Design Icons
@mdi('account', 'optional-extra-class')

// for Glyphicons
@glyph('glass', 'optional-extra-class')

@data

Output data-attributes from an array.

@data(['testing' => 123])

@haserror

Quickly output for classical $errors->has('input_name') to determine if any error messages exist for a given field.

@haserror('input_name')
    This input has an error
@endhaserror

Testing

composer test

Contributing

Contributions are welcome, thanks to y'all :)

About Appstract

Appstract is a small team from The Netherlands. We create (open source) tools for Web Developers and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.

License

The MIT License (MIT). Please see License File for more information.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap