Download the PHP package stillat/statamic-attribute-renderer without Composer

On this page you can find all versions of the php package stillat/statamic-attribute-renderer. 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 statamic-attribute-renderer

Attribute Renderer for Statamic

Attribute Renderer is a utility addon that helps create HTML attribute strings from arrays.

At a high level, it allows you to convert something like this:

to the following HTML attribute string:

The attributes renderer is also context aware, and can do things like this:

These examples are basic, and Attribute Renderer supports even more complex scenarios.

How to Install

Attribute Renderer can be installed by running the following command from the root of your project:

Converting Arrays to Attribute Strings

The simplest way to convert a key/value array of attribute details to a string is using the attributes utility function:

which produces the following result:

Resolving Variable Values

We can resolve variables from contextual data, which is supplied as the second argument to the attributes function. When specifying variable names, we simply prefix them with the $ symbol:

We can use $$ to escape the beginning of a variable string to emit string beginning with a single $:

which produces the following output:

Attribute Renderer does not support more complicated variable paths, such as nested properties, or array indices. If you need something more complicated, consider using a closure based variable resolver.

Closure Based Variable Resolvers

We can supply a Closure as the value of our attribute in order to resolve more complicated values. We will receive the context array as the first argument:

which produces:

Skippable/Ignorable Properties

By default, Attribute Renderer will emit empty strings if a value returns null:

produces:

we can let Attribute Renderer know its okay to ignore a property when producing the final result:

would now produce:

However, if the value did exist within the context:

the ignorable property is added to the output:

Rejectable Properties

Rejectable properties are similar to ignorable properties. However, if a null or empty string value is resolved for one of these values, an empty attribute string is returned, regardless of if other property values were matched:

License

Attribute Renderer is free software, released under the MIT license.


All versions of statamic-attribute-renderer with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
statamic/cms Version ^4 || ^5
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 stillat/statamic-attribute-renderer contains the following files

Loading the files please wait ....