-
-
Notifications
You must be signed in to change notification settings - Fork 112
Inline filters #59
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
Closed
Closed
Inline filters #59
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Member
|
BTW I tried it once implement this way: public function smartModifiersFilter(MacroTokens $tokens)
{
$inside = NULL;
$brackets = array();
$res = new MacroTokens;
while ($tokens->nextToken()) {
if ($tokens->isCurrent('(')) {
$brackets[] = $res->position;
} elseif ($tokens->isCurrent(')')) {
if (array_pop($brackets) === $inside) {
$res->append(')');
}
} elseif ($tokens->isCurrent('|')) {
if ($inside === end($brackets)) {
$res->append(')');
}
$name = $tokens->nextValue(MacroTokens::T_SYMBOL);
if ($name === 'escape') {
$res = $this->escapeFilter($res, end($brackets));
$tokens->nextToken(')');
$inside = NULL;
continue;
}
$res->append('$template->' . $name . '(', end($brackets));
$tokens->nextToken(',', ':');
if ($tokens->isNext() && !$tokens->isNext(')', '|')) {
$res->append(',');
}
$inside = end($brackets);
continue;
} elseif ($tokens->isCurrent(':') && $inside === end($brackets)) {
$res->append(',');
continue;
}
$res->append($tokens->currentToken());
}
if ($inside !== NULL) {
$res->append(')');
}
return $res;
} |
|
👍 |
Contributor
Author
|
Could anyone test that regexp on windows? There are some issues and I think this regexp modification might make it even worse. |
275379c to
4cdcd65
Compare
7a0b003 to
89ae5db
Compare
08e21e6 to
e23f9de
Compare
4ca485f to
efac014
Compare
e5dd124 to
ed8d395
Compare
ef2f4b7 to
f42fbe9
Compare
ed8d395 to
e1707a7
Compare
Contributor
Author
|
Could you please review it? I squashed it and I think it is ready :) |
Member
|
Great, thanks! |
dg
pushed a commit
that referenced
this pull request
Apr 23, 2016
dg
pushed a commit
that referenced
this pull request
Apr 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation:
Sometimes I need to apply the filter only on a part of macro arguments.
Current state:
{link default foo => $template->mod2($template->mod($name, 123))}Proposal:
{link this slug => ($name|mod:123|mod2)}You can also use inline filters on arguments of other filters