Unify placeholder modifiers - enable formatters as modifiers#10
Unify placeholder modifiers - enable formatters as modifiers#10
Conversation
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
henriquemoody
left a comment
There was a problem hiding this comment.
This is a great start!
We need to change the PlaceholderFormatter because right now, it's splitting the modifier to the placeholder any time it finds a |, but now that you're allowing different arguments to modifiers, they could also contain a |, for example:
{{placeholder|pattern:###\|###}}
In that case, pattern:###|### should be the pipe, but if you split it into every |, the value of $pipe could be ###. We need to at least create a test to verify if that works as expected.
| private function tryCreateFormatter(string $name, array $arguments): Formatter|null | ||
| { | ||
| /** @var class-string<Formatter> $class */ | ||
| $class = 'Respect\\StringFormatter\\' . ucfirst($name) . 'Formatter'; |
There was a problem hiding this comment.
YOu can just use the FormatterBuilder::__callStatic() here
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Co-authored-by: henriquemoody <154023+henriquemoody@users.noreply.github.com>
Fixed in commits ac22467 and 8f9f056. Updated the PlaceholderFormatter regex to handle escaped pipes: |
|
Closed in favor of #12 |
Plan: Unify Placeholder Modifiers ✅
list:or)date:Y-m-d→ DateFormatter with 'Y-m-d' arg)preg_splitwith negative lookbehind):and|)Summary of Changes
This PR implements unified placeholder modifiers as requested in the issue, allowing all formatters to be used as modifiers without creating dedicated modifier classes.
Key Changes:
FormatterModifierthat dynamically instantiates formatters based on pipe syntaxPlaceholderFormatterto includeFormatterModifierin default chain\:and\|)Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.