Re: [elixir-core:11192] Re: Proposal: Introduce string limit function.

2022-11-19 Thread Kip
> for rendering strings in UIs This is the bit that concerns me about user expectations. Rendering to a specific length can really only be done by the render engine since characters, kerning and spacing are variable width. The widest I know of is the single grapheme "﷽". And that also doesn't

Re: [elixir-core:11190] Re: Proposal: Introduce string limit function.

2022-11-19 Thread Zach Daniel
It would be great to come up with some kind of heuristic and/or consistent philosophy on what belongs in the standard library, to guide these discussions. Some kind of rubric could make these kinds of conversations easier or even prevent them entirely. For me, the main guiding principles are

[elixir-core:11190] Re: Proposal: Introduce string limit function.

2022-11-19 Thread Ben Wilson
This seems reasonably straight forward to implement in your own code base: ``` def truncate(string, length, padding \\ ".") do string |> String.slice(0, length) |> String.pad_trailing(String.length(string), padding) end ``` Not seeing a strong need to include it in the standard library.

[elixir-core:11189] Re: Proposal: Introduce string limit function.

2022-11-19 Thread Kip
That is comes from Laravel, not PHP core may be an indication it is better implemented in a library? If there is momentum towards adding it to the String module I think `String.truncate` would feel more natural to me (its also what Ruby uses). Its difficult to make guarantees about the

[elixir-core:11188] Proposal: Introduce string limit function.

2022-11-19 Thread Hassan Raza
Hi all, I came across from laravel framework, where there are a lot of useful functions, I miss those functions in Elixir, One of the functions is called limit function, I would like to have that in elixir. ``` iex>