This project is archived and is in readonly mode.
[PATCH] ActionView::TextHelper Graceful Truncate
-
etozzato
- Title changed from ActionView::TextHelper Graceful Truncate to [Patch] ActionView::TextHelper Graceful Truncate
-
Michael Schuerig
If you're truncating text with tags, you'd have to make sure that the space you see is not inside of a tag.
-
Jeremy Kemper
Nice tweak, but the implementation is not multibyte compatible.
-
etozzato
Thanks for the feedback! I'll work on updating this patch.. now I see it's not ready :)
-
Pratik
- Title changed from [Patch] ActionView::TextHelper Graceful Truncate to ActionView::TextHelper Graceful Truncate
-
CancelProfileIsBroken
- Tag changed from actionpack, tested, text_helper, truncate to actionpack, bugmash, tested, text_helper, truncate
-
Elise Huard
+1 i've had to insert a method doing that several times on projects.
-
Steve St. Martin
-1 this functionality exists in master with options[:seperator] and probably should not be backported in a bugfix release
-
Elad Meidar
-1 exists and passes tests on master (+ multibyte), tested manually too.
-
Rebecca Frankel
verified on 2-3-stable
-
Steve St. Martin
- Title changed from ActionView::TextHelper Graceful Truncate to [PATCH] ActionView::TextHelper Graceful Truncate
I've attached a patch to backport options[:seperator] and its tests to 2-3-stable
-
Steve St. Martin
ok this time for real
-
Elad Meidar
+1 Back port patch applies cleanly on 2-3-stable, tests pass.
-
Hugo Peixoto
+1 The patch applies cleanly on 2-3-stable and the tests pass.
-
RomKo
_1 The patch applies cleanly on 2-3 stable and tests pass.
-
RomKo
+1 The patch applies cleanly on 2-3 stable and tests pass.
-
Jeremy Kemper
- Assigned user set to Jeremy Kemper
- Milestone changed from 2.x to 2.3.4
How about a test with multibyte :separator?
-
Steve St. Martin
In attempting to create a test case for this identified a bug with ActiveSupport
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets... , once this ticket is complete the patch can be updated.
-
Elad Meidar
I created a working patch for 2-3-stable and master on https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...
-
Elad Meidar
Trying to test an RTL input to truncate fails:
def test_truncate_multibyte_with_seperator with_kcode 'none' do assert_equal "אלעד ...", truncate("אלעד אוכל גזר כתום", :seperator => ' ', :length => 12) end with_kcode 'u' do assert_equal "אלעד ...", truncate("אלעד אוכלת גזר כתום", :length => 10, :seperator => ' ') end end 1) Failure: test_truncate_multibyte_with_seperator(TextHelperTest) [./test/template/text_helper_test.rb:77:in `test_truncate_multibyte_with_seperator' ./test/testing_sandbox.rb:7:in `with_kcode' ./test/template/text_helper_test.rb:76:in `test_truncate_multibyte_with_seperator' ./test/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__' ./test/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `run']: <"אלעד ..."> expected but was <"אלעד או...">.stevestmartin suggests it has something to do with the fact rindex is used, and i used an RTL language as input.
should there be any difference in RTL / LTR languages in this case ?
-
Steve St. Martin
now that rindex has been corrected, here is a patch with test case to be applied against both 2-3-stable and master as master does not have a test case for this.
previous backport patch still works against 2-3-stable
-
Rizwan Reza
- Tag changed from actionpack, bugmash, tested, text_helper, truncate to actionpack, tested, text_helper, truncate
- State changed from incomplete to open
-
Rizwan Reza
- State changed from open to stale
- Milestone cleared.
stevestmartin, any chance you can provide a unified patch that applies to master? I will get it applied. And let's patch it against master only.
I am marking it as stale, please reopen and assign it to me when done. Thanks.
