aminireza-ir/laravel-easyblade

This package is abandoned and no longer maintained. The author suggests using the rezaamini-ir/laravel-easyblade package instead.

Create a easier & readable Blade view with EasyBlade

v0.1.7 2020-10-27 13:37 UTC

This package is auto-updated.

Last update: 2020-10-29 09:25:30 UTC


README

You can create a simpler and readable view with EasyBlade

Install

composer require aminireza-ir/laravel-easyblade

Usage

Use EasyBlade is too much easy like its name.

Imagine you want to write a route URL in a href in Blade You can write this code :

    <a href="{{ route('home') }}"></a>

But We create a simpler way with EasyBlade Just write :

    <a href="@route('home')"></a>

and don't use any {{ }} in your blade or don't use any PHP Pure code

Blade template engine has created to not code PHP Pure , It has created to code easier You can do it by EasyBlade :) !

Current Directives :

  • @asset('foo')
  • @url('foo')
  • @route('foo')
  • @isActive('routeName', 'active', 'deactive')
  • @count(array|collection, number )
  • @user(attr)
  • @sessionExists('name')
  • @session('name')
  • @image('address', 'cssClasses')
  • @style('style.css')
  • @script('script.js')
  • @config('app.name', 'Laravel')

Features :

  • You can pass a route name or array of route names as first parameters to@isActive directive , second parameter is a string which you want to echo in view and third parameter is a optional param and it will return a null string if nothing passed , It will be showed when current route is not equal to array or string which passed as first param
  • You can use @count directive instead of write lots of if to check count of collection or array is equal or greater than your number which passed to second param.

Examples :

  • @count
    @count([1, 2, 3], 3)
        something
    @endcount
    // return `something` because count of array is equal 3
    @count([1, 2], 3)
        true
    @endcount
    // return null because count of array is smaler than 3
  • @isActive Imagine current route is : dashboard.home
    @isActive('dashboard.home', 'active', 'deactive')
    // Return : active
    @isActive(['dashboard.home', 'dahboard.profile'], 'active', 'deactive')
    // Return : active
    @isActive('home', 'active', 'deactive')
    // Return : deactive
  • @asset
    @asset('img/header.png')
    
    // Return : http://127.0.0.1/img/header.png (Like asset() helper )
  • @route
    @route('dashboard')
    
    // Return : http://127.0.0.1/dashboard (Like route('routeName') helper )
  • @url
    @url('/home')
    
    // Return : http://127.0.0.1/home (Like url('address') helper )
  • @user
    @user('name')
    
   // It will run auth()->user()->name and return user's name
   // You don't need to check user is authenticated or not , it will check by itself
  • @sessionExists
    @sessionExists('foo')
        Session Exists
    @endsessionExists
    
    // It will run session()->exists('foo') in a condition
  • @session
    @session('name')
    
    // First it will check session exists then it will print value of session 
  • @image
    @image('img/img1.png', 'img-fuild rounded-circle')
    
    // Return a img tag with http://domain/img/img1.png file and 'img-fuild rounded-circle' class