Laravel 4 Blade on Steroids

v0.8.3 2017-07-21 06:17 UTC

This package is auto-updated.

Last update: 2023-03-21 16:33:52 UTC


Latest Stable Version License Build Status Latest Stable Version

Laravel 4 Blade on Steroids

This package provides some aditional features to Laravel Blade:

Automatic command generation

Create a file named <command>.blade.php in the templates directory and it automatically becomes a blade command.

Take the file


Whaving the contents:

<link rel="stylesheet" type="text/css" media="screen" href="@_1">

Hackers can now use the command


In their blade templates to generate:

<link rel="stylesheet" type="text/css" media="screen" href="/css/bootstrap.css">


Every sublevel in your template directory creates a level in command name. This tree:

├── default
│   ├── input.blade.php
│   ├── js.blade.php
│   └── php.blade.php
│   └── text.blade.php
├── bs
│   └── v2
│   │   ├── input.blade.php
│   │   └── form.blade.php
│   │   └── model.blade.php
│   ├── input.blade.php
│   └── form.blade.php

Would give you the following commands:




Block commands

Let's take the (silly, I know! :) @php (file php.blade.php) command as an example of a block:

    $title = 'subscribe';

Note that a block ends with @@ and you can have as many nested blocks as you want. This is the @php command's source code:


It's that simple, to create a block command you just have to add the @_BODY identifier in any part of your command.

Extending commands

You can create an @input command:

<input type="@_1" @_ATTRIBUTES />

And use it to create a





and @password commands:


HTML Attributes, Local Variables and Positional Parameters

You can dynamically create and send any number of parameters to your commands:

HTML Attributes

Take @input as an example:

@input(type=email,class=form-control,id=example,placeholder=Enter email)

Having this template

<input @_ATTRIBUTES />

It will generate this tag:

<input type="email" class="form-control" id="example" placeholder="Enter email">

Local Variables

Use a hash to define a local variable:

@input(#type=email,class=form-control,id=example,placeholder=Enter email)

And you access it by using the variable identifier @_:

<input type="@_type" @_ATTRIBUTES />

Positional Parameters

You also can access any of yours parameter by the number, let's set the type of input as the first one:

@input(email,class=form-control,id=example,placeholder=Enter email)

Then you just have to use the variable identifier followed by the parameter number:

<input type="@_1" @_ATTRIBUTES />

Another example is the Form::model(), provided by @model, this is the template

{{ Form::model(@_1, $options) }}
{{ Form::close() }}

And in your view you just have to:

    ... your controls ...

Assignment and Multi Assignment

You assign values to local (#) variables by using the equal sign:


You assign values to html attributes by doing the same, just don't put the hash sign:


And you can also do multi assignments:

@text(#label=title=First Name,class=form-control)

Superglobals (licentia poetica)

@_BODY: will be replaced by your command body

@_ATTRIBUTES: all HTML attributes generated by your command

@_PARAMETERS: it's a raw list of parameters, you can use it to pass them forward to an extended command, this is the source of @text, which extends @input:

@if (@_name->has)

@_SINGLE: if you have a command that accepts only one parameter

@h1(Hi There!)

You can use this superglobal:


But you can still use the positional variable:


Special functions


If you need to know if a variable was set you can use the ->has function:

@if (@_label->has) 
    <label class="label">@_label</label>
<input type="@_1" @_ATTRIBUTES />

The ->has function will return true or false, and then your view (in PHP) would probably look like this:

<?php if (false): ?>
    <label class="label"></label>
<?php endif; ?>
<input type="email" ... />

Steroids comes with some examples:


If you need to access one of your HTML attributes you can use the ->bare function:

<input type="@_1" class="@_class->bare" />

Delimiters and Quotation marks

As delimiters of your parameters you can use , or ;:

@input(email,class=form-control,id=example,placeholder=Enter email)

@input(email;class=form-control;id=example;placeholder=Enter email)

You don't need to use quotation marks (single ' or double "), unless you need to use any of those delimiters in your strings:

@input(email,placeholder="Hello, World!")


Steroids comes with some examples, but you can get crazy and create as many as you wish:

├── default
│   ├── css.blade.php
│   ├── form.blade.php
│   ├── h.blade.php
│   ├── input.blade.php
│   ├── js.blade.php
│   ├── model.blade.php
│   ├── p.blade.php
│   ├── php.blade.php
│   ├── row.blade.php
│   └── text.blade.php
├── bs
│   ├── md.blade.php
│   └── xs.blade.php

Easy creation of partials

Sometimes creating s simple box can be as complicated as:

<div class="row">
    <article class="col-sm-12 col-md-12 col-lg-12">
                <div class="jarviswidget-editbox">
                    @editbox('your name goes here')

                <div class="widget-body no-padding">

But after Steroids, you just need to do this in your code:

    And do whatever you need inside it!

Artisan Commands

Steroids has two artisan commands:

steroids:templates - to copy the examples to your app/config/package folder

php artisan steroids:templates

steroids:list - list all of your Steroids commands

php artisan steroids:list

view:clear - to clear you views cache

php artisan view:clear

Using the Facade directly

To compile a view using Steroids, you just have to:

 return Steroids::inject('@input(type=email,name=email,class=form-control)')



  • Laravel 4.1+
  • Composer >= 2014-01-07 - This is a PSR-4 package


Require the Steroids package:

composer require pragmarx/steroids dev-master

Add the service provider to your app/config/app.php:


To publish the configuration file you'll have to:

php artisan config:publish pragmarx/steroids

Copy the templates examples to your app folder:

php artisan steroids:templates


  • Steroids Tests Coverage is at 100%


  • Invalidate main templates when a Steroids command changes


Antonio Carlos Ribeiro


Steroids is licensed under the BSD 3-Clause License - see the LICENSE file for details


Pull requests and issues are more than welcome.