Plugin screenshot thumbnail 1/1

Adds a Twig filter that strips HTML and generates <p> and <br> tags from newlines.

Useful when you want to implement simple formatting using the Plain Text field.

Using autop Twig Filter

You can use the autop filter without parameters like this:

{{ entry.plainText|autop }}

The filter will create <p> tags from consecutive newlines and (by default) <br> tags from single newlines.

The optional parameter $br allows you to disable the <br> tag creation.

{{ entry.plainText|autop(false) }}

The plugin will also register a Twig function that you can use if needed.

{% set formattedText = autop(entry.plainText) %}

Configuring autop Twig Filter

You can create a file named autop-twig-filter.php in Craft's config folder to change the default parameter values.

For example, you can disable the default <br> tag creation globally like this:

<?php
return [
    'br' => false,
];

{{ entry.plainText|autop }} // will not generate <br> tags

Credits

Brought to you by Danail Emandiev

Installation Instructions

To install this plugin, copy the command above to your terminal.

Reviews

This plugin doesn't have any reviews.

Active Installs
3
Version
1.0.0
License
MIT
Compatibility
Craft 3
Last release
January 26, 2020