Download the PHP package belniakmedia/remarry-twig-filter without Composer

On this page you can find all versions of the php package belniakmedia/remarry-twig-filter. 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 remarry-twig-filter

remarry Twig Filter plugin for Craft CMS 5.x

Version 2.2.X

See 2.1.x for Craft CMS 4.x support See 2.0.x for Craft CMS 3.x support

NOTE: If you happen to be using a 1.x version of this plugin I highly recommend that you upgrade to the 2.x version. It SHOULD be completely backwards compatible, and it has been completely rewritten. It is now much more robust and polished for public consumption.

Install Instructions

Option 1: Install via the craft plugin store:

https://plugins.craftcms.com/

Option 2: Composer

Be sure to enable the plugin in the CP settings if you install this way

Usage Instructions

remarry Twig Filter

The remarry filter can be used with no arguments. The filter takes one argument which is either an integer to indicate the number of words to bind together at the end of actionable content, or a twig settings object. If no arguments are supplied the default value of 2 for numWords is assumed.

This plugin works on plain text and HTML documents. It will isolate text collections across DOMText nodes and inline/inline-block elements listed in our internal $inlineElements list. This means that even content like this ... there you have <b>it!</b> would end up with ... there you have&nbsp;<b>it!</b>. It also does not get tripped up by mid-paragraph elements. For example, ... this text <em>IS REALLY</em> important to me ... does not end up with non-breaking spaces added before the <em> which would be undesirable. This is because tags like <em> are recognized and treated like another DOMText node and grouped with the previously detected nodes. Only when it hits the actual end of the collection or a block level element will the content be processed. This topic is elaborated further in the setting definitions below.

Example Settings Object

Setting Details

numWords (int, default: 2)
preventHyphenBreaks (bool, default: true)
minimumWordCount (int, default: 4)
removeExtraSpaces (bool, default: true)
overrideInlineElements (null|string[], default: null)
overrideIgnoredElements (null|string[], default: null)

Usage Examples

Example with no arguments
Example with integer numWords argument
Example with full options argument
Example of reused settings object

One of the nice things about supporting a settings object is that you can define a settings object as a twig variable then re-use it throughout your code if you need to!

remarryAddElement Twig Function

Arguments

Argument Type Description
$elements array An array of element tag names you wish to add to the $elementList in argument #2. E.g.: ['a', 'span', 'strong']
$elementList 'inline' 'ignored' or array If you pass the string 'inline' the included curated inline element list will be used as a base. If you pass the string 'ignored' the included curated ignored inline element list will be used as a base. If you pass an array of tag names, that will be used as a base.

Normally you would be passing one of the string values to argument #2, however, it was deemed necessary to allow a custom array option in the event that you wanted to add new elements and remove existing elements from the curated list without needing to redefine the whole thing. Consider the following example:

This would result in inlineElements being set to the curated inline element list, minus the 'span' element, plus the 'br' element.

remarryRemElement Twig Function

See remarryAddElement definition above as this function works exactly the same way but removes an element rather than adds one and the function's name is slightly different.

<br> Tag Special Handling Details

By default, this plugin treats <br> tags like block level elements in that all buffered DOMText nodes and DOMElement nodes matching the curated inline elements list are processed as collection once a <br> tag is encountered. The only difference is that unlike block level elements, the <br> elements are not traversed since they have no child nodes or content. The <br> tag is maintained in the output. This means that the following HTML would be processed in the following manner:

If for some reason you need to disable this behavior, simply add the 'br' tag name to the overrideInlineElements setting to have the plugin treat that tag as a normal inline element:

When the 'br' element is added to the inline elements list, the above example would then output:

Included Curated Inline Element List

The curated list of inline elements was derived from the MDN Article on HTML Inline Elements.

[ 'a', 'abbr', 'acronym', 'b', 'bdi', 'bdo', 'big', 'cite', 'data', 'del', 'dfn', 'em', 'i', 'ins', 'kbd', 'label', 'mark', 'q', 's', 'samp', 'small', 'span', 'strong', 'time', 'u', 'tt', 'var', ]

Included Curated Ignored Inline Element List

The curated list of ignored inline elements was derived from the MDN Article on HTML Inline Elements.

[ 'audio', 'button', 'canvas', 'code', 'datalist', 'img', 'math', 'meter', 'noscript', 'object', 'output', 'param', 'picture', 'pre', 'progress', 'ruby', 'script', 'select', 'sub', 'sup', 'svg', 'textarea', 'track', 'video', 'wbr', 'xmp', ]

FAQs

What does this do?

What is a paragraph widow anyway?

Why should I care about this?

How do you "Fix" paragraph widows?

Why do I need this plugin then?

Shouldn't this just be a few lines of string replacement code?

Brought to you by Belniak Media Inc.


All versions of remarry-twig-filter with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.2
craftcms/cms Version ^5.0.0
ext-dom Version *
ext-mbstring Version *
ext-libxml Version *
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 belniakmedia/remarry-twig-filter contains the following files

Loading the files please wait ....