TopShelfCraft / Wordsmith

A plugin for Craft CMS to help you manage and manipulate text.
Other
30 stars 20 forks source link

Make `trim` interoperable with native Twig function #27

Open chasegiunta opened 5 years ago

michaelrog commented 5 years ago

Currently, Wordsmith's trim overrides Twig's core function. (This is intentional.) However, we could make them interoperable by adding some matching params to Wordsmith's trim function.

The new signature of our trim function would be something like:

public function trim($s, $characterMask = null, $side = 'both', $chars = null) : string

Pros:

Cons:

Documentation options

  1. Silent compatibility (i.e. Stringy params in documentation, Twig's params working silently as a bonus)
  2. Deprecate the Stringy params in favor of documented compatibility with Twig's params
  3. Document both param variations

I would welcome a PR to dev to address this.