{"id":15525159,"url":"https://github.com/antonioribeiro/steroids","last_synced_at":"2025-07-16T15:36:06.658Z","repository":{"id":13285372,"uuid":"15971179","full_name":"antonioribeiro/steroids","owner":"antonioribeiro","description":"Laravel 4 Blade on Steroids","archived":false,"fork":false,"pushed_at":"2017-07-21T06:17:35.000Z","size":120,"stargazers_count":95,"open_issues_count":0,"forks_count":6,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-28T01:53:39.983Z","etag":null,"topics":["laravel-blade","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonioribeiro.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-16T15:07:25.000Z","updated_at":"2023-08-30T13:36:47.000Z","dependencies_parsed_at":"2022-09-06T05:20:39.541Z","dependency_job_id":null,"html_url":"https://github.com/antonioribeiro/steroids","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fsteroids","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fsteroids/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fsteroids/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonioribeiro%2Fsteroids/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonioribeiro","download_url":"https://codeload.github.com/antonioribeiro/steroids/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248884627,"owners_count":21177454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["laravel-blade","php"],"created_at":"2024-10-02T10:55:14.670Z","updated_at":"2025-04-14T12:50:45.176Z","avatar_url":"https://github.com/antonioribeiro.png","language":"PHP","funding_links":[],"categories":["Packages"],"sub_categories":["Helpers/General"],"readme":"# Steroids v0.7\r\n\r\n[![Latest Stable Version](https://poser.pugx.org/pragmarx/steroids/v/stable.png)](https://packagist.org/packages/pragmarx/steroids) [![License](https://poser.pugx.org/pragmarx/steroids/license.png)](https://packagist.org/packages/pragmarx/steroids) [![Build Status](https://travis-ci.org/antonioribeiro/steroids.png)](https://travis-ci.org/antonioribeiro/steroids) [![Latest Stable Version](https://coveralls.io/repos/antonioribeiro/steroids/badge.png)](https://coveralls.io/r/antonioribeiro/steroids)\r\n\r\n## Laravel 4 Blade on Steroids\r\n\r\nThis package provides some aditional features to Laravel Blade:\r\n\r\n### Automatic command generation\r\n\r\nCreate a file named `\u003ccommand\u003e.blade.php` in the templates directory and it automatically becomes a blade command.\r\n\r\nTake the file\r\n\r\n    default\\css.blade.php\r\n\r\nWhaving the contents:\r\n\r\n    \u003clink rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"@_1\"\u003e\r\n\r\nHackers can now use the command\r\n\r\n    @css(/css/bootstrap.css)\r\n\r\nIn their blade templates to generate:\r\n\r\n    \u003clink rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"/css/bootstrap.css\"\u003e\r\n\r\n### Subtemplating\r\n\r\nEvery sublevel in your template directory creates a level in command name. This tree:\r\n\r\n```\r\n├── default\r\n│   ├── input.blade.php\r\n│   ├── js.blade.php\r\n│   └── php.blade.php\r\n│   └── text.blade.php\r\n├── bs\r\n│   └── v2\r\n│   │   ├── input.blade.php\r\n│   │   └── form.blade.php\r\n│   │   └── model.blade.php\r\n│   ├── input.blade.php\r\n│   └── form.blade.php\r\n```\r\n\r\nWould give you the following commands:\r\n\r\n    @input()\r\n    @js()\r\n    @php()\r\n    @text()\r\n\r\n    @bs.input()\r\n    @bs.form()\r\n\r\n    @bs.v2.input()\r\n    @bs.v2.form()\r\n    @bs.v2.model()\r\n\r\n### Block commands\r\n\r\nLet's take the (silly, I know! :) `@php` (file `php.blade.php`) command as an example of a block:\r\n\r\n    @php\r\n        $title = 'subscribe';\r\n    @@\r\n\r\nNote that a block ends with `@@` and you can have as many nested blocks as you want. This is the `@php` command's source code:\r\n\r\n    \u003c?php \r\n        @_BODY;\r\n    ?\u003e\r\n\r\nIt's that simple, to create a block command you just have to add the `@_BODY` identifier in any part of your command.\r\n\r\n### Extending commands\r\n\r\nYou can create an `@input` command:\r\n\r\n    \u003cinput type=\"@_1\" @_ATTRIBUTES /\u003e\r\n\r\nAnd use it to create a \r\n\r\n`@text`:\r\n    \r\n    @input(text,@_PARAMETERS)\r\n\r\n`@email`:\r\n\r\n    @input(email,@_PARAMETERS)\r\n\r\nand `@password` commands:\r\n\r\n    @input(password,@_PARAMETERS)\r\n\r\n### HTML Attributes, Local Variables and Positional Parameters\r\n\r\nYou can dynamically create and send any number of parameters to your commands:\r\n\r\n#### HTML Attributes\r\n\r\nTake @input as an example:\r\n\r\n    @input(type=email,class=form-control,id=example,placeholder=Enter email)\r\n\r\nHaving this template\r\n\r\n    \u003cinput @_ATTRIBUTES /\u003e\r\n\r\nIt will generate this tag:\r\n\r\n    \u003cinput type=\"email\" class=\"form-control\" id=\"example\" placeholder=\"Enter email\"\u003e\r\n\r\n#### Local Variables\r\n\r\nUse a hash to define a local variable:\r\n\r\n    @input(#type=email,class=form-control,id=example,placeholder=Enter email)\r\n\r\nAnd you access it by using the variable identifier `@_`:\r\n\r\n    \u003cinput type=\"@_type\" @_ATTRIBUTES /\u003e\r\n\r\n#### Positional Parameters\r\n\r\nYou also can access any of yours parameter by the number, let's set the type of input as the first one:\r\n\r\n    @input(email,class=form-control,id=example,placeholder=Enter email)\r\n\r\nThen you just have to use the variable identifier followed by the parameter number:\r\n\r\n    \u003cinput type=\"@_1\" @_ATTRIBUTES /\u003e\r\n\r\nAnother example is the Form::model(), provided by `@model`, this is the template\r\n\r\n    {{ Form::model(@_1, $options) }}\r\n        @_BODY\r\n    {{ Form::close() }}\r\n\r\nAnd in your view you just have to:\r\n\r\n    @model($user,url=/profile)\r\n        ... your controls ...\r\n    @@\r\n\r\n#### Assignment and Multi Assignment\r\n\r\nYou assign values to local (#) variables by using the equal sign:\r\n\r\n    @text(#label=form-control)\r\n\r\nYou assign values to html attributes by doing the same, just don't put the hash sign:\r\n\r\n    @text(class=form-control)\r\n\r\nAnd you can also do multi assignments:\r\n\r\n    @text(#label=title=First Name,class=form-control)\r\n\r\n### Superglobals (licentia poetica)\r\n\r\n`@_BODY`: will be replaced by your command body\r\n\r\n`@_ATTRIBUTES`: all HTML attributes generated by your command\r\n\r\n`@_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`:\r\n\r\n    @if (@_name-\u003ehas)\r\n        @input(text,name=@_1,@_PARAMETERS)\r\n    @else\r\n        @input(text,@_PARAMETERS)\r\n    @endif\r\n\r\n`@_SINGLE`: if you have a command that accepts only one parameter \r\n\r\n    @h1(Hi There!)\r\n\r\nYou can use this superglobal:\r\n\r\n    \u003ch1\u003e@_SINGLE\u003c/h1\u003e\r\n\r\nBut you can still use the positional variable:\r\n\r\n    \u003ch1\u003e@_1\u003c/h1\u003e\r\n\r\n### Special functions\r\n\r\n#### -\u003ehas\r\n\r\nIf you need to know if a variable was set you can use the `-\u003ehas` function:\r\n\r\n    @if (@_label-\u003ehas) \r\n        \u003clabel class=\"label\"\u003e@_label\u003c/label\u003e\r\n    @endif\r\n    \u003cinput type=\"@_1\" @_ATTRIBUTES /\u003e\r\n\r\nThe `-\u003ehas` function will return `true` or `false`, and then your view (in PHP) would probably look like this:\r\n\r\n    \u003c?php if (false): ?\u003e\r\n        \u003clabel class=\"label\"\u003e\u003c/label\u003e\r\n    \u003c?php endif; ?\u003e\r\n    \u003cinput type=\"email\" ... /\u003e\r\n\r\nSteroids comes with some examples:\r\n\r\n#### -\u003ebare\r\n\r\nIf you need to access one of your HTML attributes you can use the `-\u003ebare` function:\r\n\r\n    \u003cinput type=\"@_1\" class=\"@_class-\u003ebare\" /\u003e\r\n\r\n### Delimiters and Quotation marks\r\n\r\nAs delimiters of your parameters you can use `,` or `;`:\r\n\r\n    @input(email,class=form-control,id=example,placeholder=Enter email)\r\n\r\n    @input(email;class=form-control;id=example;placeholder=Enter email)\r\n\r\nYou don't need to use quotation marks (single `'` or double `\"`), unless you need to use any of those delimiters in your strings:\r\n\r\n    @input(email,placeholder=\"Hello, World!\")\r\n\r\n### Examples\r\n\r\nSteroids comes with some examples, but you can get crazy and create as many as you wish:\r\n\r\n```\r\n├── default\r\n│   ├── css.blade.php\r\n│   ├── form.blade.php\r\n│   ├── h.blade.php\r\n│   ├── input.blade.php\r\n│   ├── js.blade.php\r\n│   ├── model.blade.php\r\n│   ├── p.blade.php\r\n│   ├── php.blade.php\r\n│   ├── row.blade.php\r\n│   └── text.blade.php\r\n├── bs\r\n│   ├── md.blade.php\r\n│   └── xs.blade.php\r\n```\r\n\r\n### Easy creation of partials\r\n\r\nSometimes creating s simple box can be as complicated as:\r\n\r\n    \u003cdiv class=\"row\"\u003e\r\n        \u003carticle class=\"col-sm-12 col-md-12 col-lg-12\"\u003e\r\n                \u003cdiv\u003e\r\n                    \u003cdiv class=\"jarviswidget-editbox\"\u003e\r\n                        @editbox('your name goes here')\r\n                    \u003c/div\u003e\r\n\r\n                    \u003cdiv class=\"widget-body no-padding\"\u003e\r\n                        @_BODY\r\n                    \u003c/div\u003e\r\n                \u003c/div\u003e\r\n            \u003c/div\u003e\r\n        \u003c/article\u003e\r\n    \u003c/div\u003e\r\n\r\nBut after Steroids, you just need to do this in your code:\r\n\r\n    @box\r\n        And do whatever you need inside it!\r\n    @@\r\n\r\n### Artisan Commands\r\n\r\nSteroids has two artisan commands:\r\n\r\n`steroids:templates` - to copy the examples to your `app/config/package` folder\r\n\r\n    php artisan steroids:templates\r\n\r\n`steroids:list` - list all of your Steroids commands\r\n\r\n    php artisan steroids:list\r\n\r\n`view:clear` - to clear you views cache\r\n\r\n    php artisan view:clear\r\n\r\n### Using the Facade directly\r\n\r\nTo compile a view using Steroids, you just have to:\r\n\r\n     return Steroids::inject('@input(type=email,name=email,class=form-control)')\r\n\r\n### Installation\r\n\r\n#### Requirements\r\n\r\n- Laravel 4.1+\r\n- Composer \u003e= 2014-01-07 - This is a PSR-4 package\r\n\r\n#### Installing\r\n\r\nRequire the Steroids package:\r\n\r\n    composer require pragmarx/steroids dev-master\r\n\r\nAdd the service provider to your app/config/app.php:\r\n\r\n    'PragmaRX\\Steroids\\Vendor\\Laravel\\ServiceProvider',\r\n\r\nTo publish the configuration file you'll have to:\r\n\r\n    php artisan config:publish pragmarx/steroids\r\n\r\nCopy the templates examples to your app folder: \r\n\r\n    php artisan steroids:templates\r\n\r\n### Tests\r\n\r\n- Steroids Tests Coverage is at 100%\r\n\r\n### TODO\r\n\r\n- Invalidate main templates when a Steroids command changes\r\n\r\n### Author\r\n\r\n[Antonio Carlos Ribeiro](http://twitter.com/iantonioribeiro) \r\n\r\n### License\r\n\r\nSteroids is licensed under the BSD 3-Clause License - see the `LICENSE` file for details\r\n\r\n### Contributing\r\n\r\nPull requests and issues are more than welcome.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonioribeiro%2Fsteroids","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonioribeiro%2Fsteroids","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonioribeiro%2Fsteroids/lists"}