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
Inline filters #59
Closed
Closed
Inline filters #59
Conversation
This file contains 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
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;
} |
👍 |
Could anyone test that regexp on windows? There are some issues and I think this regexp modification might make it even worse. |
dg
force-pushed
the
master
branch
6 times, most recently
from
June 19, 2015 12:26
275379c
to
4cdcd65
Compare
dg
force-pushed
the
master
branch
6 times, most recently
from
October 12, 2015 17:32
7a0b003
to
89ae5db
Compare
dg
force-pushed
the
master
branch
3 times, most recently
from
November 7, 2015 01:32
08e21e6
to
e23f9de
Compare
dg
force-pushed
the
master
branch
3 times, most recently
from
March 17, 2016 23:38
4ca485f
to
efac014
Compare
matej21
force-pushed
the
feature/inline_filters
branch
from
April 16, 2016 16:01
e5dd124
to
ed8d395
Compare
dg
force-pushed
the
master
branch
2 times, most recently
from
April 21, 2016 13:01
ef2f4b7
to
f42fbe9
Compare
matej21
force-pushed
the
feature/inline_filters
branch
from
April 22, 2016 13:14
ed8d395
to
e1707a7
Compare
Could you please review it? I squashed it and I think it is ready :) |
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