Code Monkey home page Code Monkey logo

laravel-easyblade's Introduction

Scrutinizer Code Quality Build Status

laravel EasyBlade

You can create a simpler and more readable view with EasyBlade

Installation

composer require rezaamini-ir/laravel-easyblade

Usage

Using EasyBlade is, just like its name, super easy!

Imagine that you want to write a route URL in a href in Blade You will have to write this code :

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

But by using EasyBlade, Just write :

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

and don't use "{{ }}" or any pure PHP code

Blade template engine was not created for pure PHP code, rather, it was created to code easier. You can pass 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')
  • @old('name', 'Reza')

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 an optional param and it will return a null string if nothing was passed , It will be showed when the current route is not equal to array or string which passed as first param
  • You can use @count directive instead of writing lots of if statements to check if the count of the collection or array is equal to or greater than your number which was passed to the 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
  • @old
    @old('name', $user->name)
    
    // Return something like : {{ old('name', $user->name) }}
  • @script
    @script('/js/script.js')
    // Return script tag : <script src="/js/script.js"></script>
      
    @script('/js/script.js', true) // Second and third parameter is optional
    // Return script tag with defer : <script src="/js/script.js" defer></script>  
  • @style
    @style('/css/app.css')
    // Return link tag : <link rel="stylesheet" href="/css/app.css">

laravel-easyblade's People

Contributors

alighorbani1381 avatar arahmanii avatar procedurally-generated-human avatar reziamini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.