Download the PHP package mauricesnip/twig-elementary-bundle without Composer

On this page you can find all versions of the php package mauricesnip/twig-elementary-bundle. 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 twig-elementary-bundle

Twig Elementary Bundle Logo

Twig Elementary Bundle

Build Twig components in the most elemental way, without a large footprint.

Heads up!

⚠️ This bundle is in early development stage and should not be used in production.

The examples below require Twig's HtmlExtension to be installed. See the documentation for html_classes on how to install this extension.

Installation

Run the following command to install this package with Composer:

Basic usage

Start by extending from element-entry.html.twig, which provides switching between normal and void elements automatically.

Using the template above, the following include:

Will render:

Templates

element.html.twig

Renders a normal element.

Blocks

Name Description
element Renders the full element.
start_tag Renders the start tag with all of it's attributes.
end_tag Renders the end tag.
contents Renders the element's contents.

Parameters

Name Type Default Description
attributes Object {} The HTML-attributes to render, eg.: { id: 'foo' }.
contents String undefined The contents of the element.
tag_name String span The HTML element's tag name, eg.: a, div or p.
is_raw_contents Boolean undefined Whether to render raw contents or not.

element-void.html.twig

Renders a void element. Extends element.html.twig.

Blocks

Name Description
element Renders the full element.
start_tag Renders the start tag with all of it's attributes.

Parameters

Name Type Default Description
attributes Object {} The HTML-attributes to render, eg.: { id: 'foo' }.
tag_name String span The HTML element's tag name, eg.: a, div or p.

element-entry.html.twig

Renders a normal or void element automatically.

For blocks and parameters, see the documentation for normal and void element above. Extends element.html.twig or element-void.html.twig, based on the provided tag_name.

Advanced usage

If you want to extend from your newly created component, be sure to allow for variables to receive values from their child components. Continuing on the basic usage example:

Variable overriding

Note that this also enables variable overriding for include or embed, for example:

Will render:

attributes quirks

Be aware that overriding attributes.class will replace the entire class attribute, since Twig does not support deep merge. Nor does merge concatenate string values in any way. Thus, the following include:

Will render:

Hence classes|default in the advanced usage example for appending classes to the final output. In this case, the following:

Will render:

Adding content

You can provide contents as a variable, which is mostly used for text content. Markup is supported by setting is_raw_contents to true. See documentation for element.html.twig.

Or, what you probably want most of the time, override the contents block.

Concrete example

Skeletons provide a base for components that come in many different flavors (or types) to extend from. Taking the advanced usage example one step further:

And a product card extending from the above skeleton:

This inherits all the way up to element.html.twig, adding features along the way. With that in mind, the following include:

Will render:

Visualized


All versions of twig-elementary-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
twig/twig Version ^2.0 || ^3.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 mauricesnip/twig-elementary-bundle contains the following files

Loading the files please wait ...