experience / entitle
AP-style title capitalisation for Craft CMS.
Installs: 659
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 2
Forks: 1
Type:craft-plugin
Requires
- craftcms/cms: ^3.0.0
Requires (Dev)
- codeception/codeception: dev-master
This package is auto-updated.
Last update: 2021-11-03 19:31:50 UTC
README
Entitle is a Craft plugin which makes it easy to apply AP-style title capitalisation rules to the text on your website.
Requirements
Each release of Entitle is automatically tested against PHP 7.1 and above. It's also manually tested on the most recent version of Craft.
PHP 7.0 support
In theory, Entitle should be compatible with PHP 7.0. In practise, it's impossible to test this, because 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 Entitle, either search for "Entitle" in the Craft Plugin Store, or add it as a Composer dependency.
Here's how to install Entitle using Composer.
-
Open your terminal, and navigate to your Craft project:
cd /path/to/project
-
Add Entitle as a project dependency:
composer require experience/entitle
-
In the Control Panel, go to "Settings → Plugins", and click the "Install" button for Entitle
Configuration
Entitle allows you to specify "protected" words, which are not subject to the AP capitalisation rules. This is useful for ensuring that acronyms, brand names, and the like are not modified.
After installing Entitle (as described above), navigate to its settings page, and enter your "protected" words as a comma-delimited string.
Usage
There are three ways to use Entitle:
- As a Craft service.
- As a template variable.
- As a Twig filter.
Service
The Entitle service exposes a single method, capitalize
. The method accepts an input string, and returns the correctly-capitalised result.
// Result: 'Of Mice and Men'
Entitle::getInstance()->entitle->capitalize('of mice and men');
Template variable
Entitle exposes a single template variable, capitalize
. As with the service method of the same name, it accepts an input string, and returns the correctly-capitalised result.
// Result: 'Fear and Loathing in Las Vegas'
{{ craft.entitle.capitalize('fear and loathing in las vegas') }}
Twig filter
Entitle exposes a single Twig filter, entitle
.
// Result: 'The Hound of the Baskervilles'
{{ 'the hound of the baskervilles'|entitle }}