Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make trim interoperable with native Twig function #27

Open
chasegiunta opened this issue Oct 19, 2019 · 1 comment
Open

Make trim interoperable with native Twig function #27

chasegiunta opened this issue Oct 19, 2019 · 1 comment

Comments

@chasegiunta
Copy link

No description provided.

@michaelrog michaelrog changed the title Conflicts with twig's native trim filter Make trim interoperable with native Twig function Oct 21, 2019
@michaelrog
Copy link
Member

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:

  • Affordance for anyone familiar with Twig's trim
  • Prevent accidentally manifesting bugs in users' templates if they are already using Twig's trim when they install Wordsmith

Cons:

  • Added complexity because we need to add conditional branches to Wordsmith's trim
  • Redundancy w/ trimLeft and trimRight — Do we deprecate these?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants