Download the PHP package kagagnon/bem-blade without Composer
On this page you can find all versions of the php package kagagnon/bem-blade. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package bem-blade
Installation
Install via composer with
After successfully installing BEM Blade, add the service provider in your app configs.
The service provider will boot and register new directives in the Blade engine.
Optional configurations
You can publish the config file with the following command:
You can then change your element and modifier separators to your liking.
How to use
Blocks
You can create a new block with the directive @bem( $block_name )
. Once the block if finished,
you can use @endbem
to close the block. BEM block can be nest for sub-module. So this:
is a valid syntax.
Classes
To generate a class, you can use @bemclass( [ string|array $element, [ string|array $modifiers ] ] )
.
- Passing no arguments generate the block name.
- Passing a string as first argument generate the block name with an element.
- Passing an array as first argument generate the block name with the modifiers.
- Passing a string and an array generate a block name with an element and its modifiers.
-
Passing 2 strings generate a block name with an element and explode the string on spaces to generate the modifiers.
Check the examples below:
HTML example
Result to :
Create node with @bem
You can pass argument to @bem
to automatically generate an HTML tag.
To do so, you can pass the tag name as second argument and, optionally, an array of attributes.
You can also skip the tag name and pass an array as second argument. That will create an HTML element base on the default_tag
configuration.
Additionally, if you set create_tag
to true, @bem()
will always create a tag base on
the default_tag
configuration if only 1 argument is passed.
To pass modifiers to the tag, simply pass _modifiers
in the array: an array for multi-modifiers ou a string for single modifier.