How it works

You can throw pretty much anything at Meld, and it will do its best to make sense of the madness.

If either the prefix or the suffix is an array, Meld returns an array of results. Otherwise, Meld returns a single string.

Meld will do its best to coerce each prefix and suffix into a string (assuming it isn't already). In practical terms, this means:

Integers are converted to their string equivalent;

Floats are converted to their string equivalent;

Booleans are converted to "1" (true) or "0" (false);

Objects which implement the __toString method are converted to their string representation;

Everything else is converted to an empty string.

It's worth noting that even if the prefix or suffix is an empty string, Meld will still include it in the results. If you don't want this to happen, sanitise your prefixes and suffixes before passing them to Meld. Rubbish in, rubbish out.

Requirements

Each release of Meld is automatically tested against PHP 7.1 and above. It is also manually tested on the most recent version of Craft.

PHP 7.0 support

In theory, Meld should be compatible with PHP 7.0. In practise, it's impossible to test this.

We use Codeception for testing (as is the Yii way), and the Codeception dependency tree includes components which only work with PHP 7.1+.

Unfortunately there's nothing we can do about that.

Installation

To install Meld, either search for "Meld" in the Craft Plugin Store, or add it as a Composer dependency.

Here's how to install Meld using Composer.

Open your terminal, and navigate to your Craft project:

cd /path/to/project

Add Meld as a project dependency:

composer require experience/meld

In the Control Panel, go to "Settings → Plugins", and click the "Install" button for Meld

Usage

Meld can cope with a wide variety of prefixes and suffixes, from basic strings, all the way up to arrays of objects. Refer to the "How it works" section, above, for additional information.

Use the Meld filter in exactly the same way as any other Twig filter, with the prefix to the left of the pipe, and the suffix as the filter argument.