Permalink
Browse files

merged branch umpirsky/truncate-patch (PR #61)

This PR was merged into the master branch.

Commits
-------

d67bc7e Rtrimmed truncated value.

Discussion
----------

Rtrimmed truncated value.

Trimmed trailing spaces.

Example:

before: `Lorem ipsum ...`
after:    `Lorem ipsum...`

---------------------------------------------------------------------------

by umpirsky at 2012-06-30T11:06:49Z

@fabpot Ping.

---------------------------------------------------------------------------

by michelsalib at 2012-07-01T22:45:30Z

This behavior looks weird. At least, I don't expect it...
Can it be triggered using a parameter ? Also can you provide some tests ?

---------------------------------------------------------------------------

by umpirsky at 2012-07-02T06:15:16Z

Isn't it wrong to have white space before ...?

---------------------------------------------------------------------------

by michelsalib at 2012-07-02T06:31:22Z

Yes it is right. Can you provide test ?

---------------------------------------------------------------------------

by umpirsky at 2012-07-02T14:52:01Z

Then we don't need tests, simply reject my PR. I will implement custom extension for this because I find text `Lorem ipsum ...` invalid.

---------------------------------------------------------------------------

by michelsalib at 2012-07-02T14:54:09Z

Sorry for the misunderstanding. I think your PR is valid. It just deserves a unit test ;)

---------------------------------------------------------------------------

by umpirsky at 2012-07-02T15:48:02Z

But there is no test for any of extensions?

---------------------------------------------------------------------------

by michelsalib at 2012-07-02T16:07:11Z

Well, too bad.
Whatever, I am +1 for this PR

---------------------------------------------------------------------------

by umpirsky at 2012-07-02T17:15:26Z

I would be happy to contribute tests. I can't promise, but if I find some time, I will fix a PR.

---------------------------------------------------------------------------

by pjedrzejewski at 2012-12-03T11:53:29Z

👍  for this one.
  • Loading branch information...
2 parents 91336a6 + d67bc7e commit d1990ffaca93302709d1306d50ae153adb169f49 @fabpot fabpot committed Dec 15, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/Twig/Extensions/Extension/Text.php
@@ -59,7 +59,7 @@ function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $pres
}
}
- return mb_substr($value, 0, $length, $env->getCharset()) . $separator;
+ return rtrim(mb_substr($value, 0, $length, $env->getCharset())) . $separator;
}
return $value;
@@ -96,7 +96,7 @@ function twig_truncate_filter(Twig_Environment $env, $value, $length = 30, $pres
}
}
- return substr($value, 0, $length) . $separator;
+ return rtrim(substr($value, 0, $length)) . $separator;
}
return $value;

0 comments on commit d1990ff

Please sign in to comment.