Download the PHP package pug/bemto without Composer

On this page you can find all versions of the php package pug/bemto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bemto

Bemto

Latest Stable Version License Build Status StyleCI Test Coverage Code Climate Dependencies

Smart mixins for writing BEM in Pug-php.

This project is a port of kizu/bemto for Phug and it's also compatible with Pug-php.

Table of Contents

  1. Install & Use
  2. Features

    • Blocks
    • Elements
    • Modifiers
    • Changing the tag name
    • Attributes
    • Context
    • Redefining tag's metadata
  3. Settings

    • Adding Prefix
    • Setting for Element syntax
    • Setting for Modifier syntax
    • Setting for allowing nested elements
    • Scope for the settings
    • Setting for the output syntax of the elements/modifiers
  4. Using for building complex mixins

Install & Use

This will make bemto features available in your tempaltes:

would render to something like

Features

Blocks

“Block” is the main thing there. It creates the block from the first passed class and creates the context for all nested elements.

You can create block calling the b mixin with some class attached to it:

That would render as

While the simple block's syntax, of course, is harder than the simple Pug's tags, the main point is to create the contexts for elements.

Elements

“Element” is a accessory element of the block. You can read on the concept of the elements in the bem methodology, or in the great article by Nicolas Gallagher (see the “Structured class names” part). Elements often are written using the block's name plus element's name with some separator (often __ or -) in-between.

Bemto gives a convenient way to declare the elements: just use the e mixin inside any block context:

This would render like

Context of the element

Note that bemto uses the first classname of the block as a context for further elements. If you'd like to use another class without changing the order, you can mark it with __ in the end:

This way instead of foo bemto would base the nested elements from the bar:

Modifiers

“Modifier” is a state of the block or element. It is often written with the addition of it's type and/or value after the single underscore like block_mode_foo or just block_foo. However, at the most cases, the block must contain either the original block/element's class, either the modifier class.

Bemto makes it easy to write such modifiers, 'cause you don't need now to write the same block's name twice:

Becomes

See? You write just .block_foo but by fact get the .block.block_foo instead!

But what if you need to have more than one modifier on one block or element? Bemto have a way to do so: add a class to your block or element starting with a modifier token:

and that would render as

You can also use shorter modifier syntax like class="block -modifier" (but only when this syntax won't be used for delimiting full modifiers or elements).

this would render to

Changing the tag name

By default the blocks and elements render as divs. You can change it by passing the desired tag name as the first class in uppercase:

Or by passing an options object with a tag param:

Either way would render as

Attributes

Like any Pug tag or mixin, blocks and elements can take attributes that would go to the desired tags:

would render like

Automatic attributes

There are some tags like img that must have at least one attribute set. Bemto would create attributes with some predefined values for such tags. So, for images this code — +b.image(src="foo.png") would render <img alt="" class="image" src="foo.png"/> — you can see that in that case there is the added empty alt.

Also, in some cases there is a need to adjust some attributes according to other ones. For img if the alt is set, but the title is not we'd need to set it to empty, 'cause there'd be a inconsistency between browsers (IE would show the title bubble for alt). And from the other side, if there is only title set in an image, we'd need to clone it to alt. Bemto do all those things.

Context

Look at the previous example: you have there some excess code that you can throw away. It's the ('a') part — as long as you set the href attribute, the block would automagically become the link. Also, there are other tags that you can omit: li in ul or ol context, or span in any already inline context.

So, here is a bigger example:

Would render to

For now that's all, but there would be other contexts in the future of bemto.

Redefining tag's metadata

In a case you'd like some tag to set a different context, i.e. to override it's content_type, you can use a metadata option for the block/element. For example, if you'd like a link to have block context, you can redefine it in this way:

would render as

Settings

There are some settings you can set for different syntaxes of BEM.

For doing so, you must set them after including the bemto like this:

Here you can see all available settings with their default values.

Adding Prefix

If you'd like to prefix all your bemto-generated blocks, you can set the prefix setting to a String or an Object.

Strings for prefix setting

If you'd set a string, it would be just prepended to the names of all blocks:

and that would then render as

Note that if you had already used this prefix in a classname, it won't be added, so you won't have occasional duplicated prefixes.

Objects for prefix setting

If you'd want to have more control over prefixes, you can use a special object instead of a string:

Look at the above example, it have all the variations the prefix object accepts:

Setting for Element syntax

If you don't like the default elements syntax with the __ delimiter, you can set using the element setting:

this would render to

Setting for Modifier syntax

If you'd like to use different modifier syntax, like the one Nicolas Gallagher mentioned in his article, you can use the modifier setting:

and that would expand to

Setting for allowing nested elements

There can be cases when you could want to make elements of elements, i.e. when using element names instead of block names:

renders by default to

If you'd like to have foo__bar__baz in the output instead, you can set the flat_elements to false:

This would render with the nested element:

Scope for the settings

If you'll need to have some settings just in a certain scope, you can wrap your code in bemto_scope mixin, passing your desired settings right into it:

Would render as

Setting for the output syntax of the elements/modifiers

If you'd like to use different syntax of the element/modifier delimiter in Pug source and the html output, you can use the ouput_element and output_modifier settings, otherwise the same delimiter as in the element and modifier settings would be used.

would output

You can see how the source uses the - for element and -- for modifier, but the result gets __ and _ instead.

Setting for delimiters between classnames

If you'd like to have extra delimieters between the rendered classnames for clarity, you can use a class_delimiter setting:

Would be rendered as

Note that there would be always added spaces around the given delimiter, so you don't need to include them in the setting's value.

Using for building complex mixins

This is somewhat obvious, but I must mention that the bemto blocks would be great for using as the bricks for building more complex blocks. The Pug mixins work in the way where you can translate any attributes through to the any inner blocks. So you can do this:

And then use it in this way:

And that would render to

There you can see almost all of the bemto features that can be used for any mixin with attributes variable attached to any inner bemto block inside of it.

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Sponsor

Professionally supported pug/bemto


All versions of bemto with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
phug/compiler Version ^1.0.0
phug/formatter Version ^1.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pug/bemto contains the following files

Loading the files please wait ....