Allow capture group substitution in case content#1
Allow capture group substitution in case content#1Kindari wants to merge 1 commit intocroxton:developfrom Kindari:develop
Conversation
This adds numeric and named capture group replacement to case content
return data.
Example:
{exp:switchee variable="{segment_3}"}
{!-- detect pagination, for example --}
{case value="#^P(?P<page>\d+)$#|''"}
We are on page #{switchee:page}
{/case}
{/exp:switchee}
|
Looks good, but could you please apply your patch to the develop branch instead? That's the beta version of Switchee and will be the next stable release. Many thanks https://github.com/croxton/Switchee/blob/develop/pi.switchee.php |
|
Hi, I did submit the request on the develop branch, as the top of this page says: "Kindari wants someone to merge 1 commit into croxton:develop from kindari:develop". |
|
Sorry that's what happens when you've been up all night :) I can see a possible problem with this when using nesting, as the nested switchee tags start {switchee ...} It won't trip up the tag pair regex but it could increase recursion. Maybe we need to use different prefix text for the captured values or add a parameter to specify the prefix. Thoughts? |
|
I would either change the prefix (if so configurable prefix would be preferable for users) or I would change the pattern to check against switchee:, the difference between the nested tag and the captured variable being a colon syntax. |
|
Hmm, how about using parentheses {(page)} ? I quite like that it echos the grouping syntax. What do you think? |
This adds numeric and named capture group replacement to case content
return data.
Example: