use css truncate everywhere and remove StringUtils.truncate function (#513)

Co-authored-by: robs <git@robs.social>
This commit is contained in:
Robert Kleinschusterandrobs authored and GitHub committed 2024-12-13 12:23:12 -08:00
1 parent 53e106dac2
commit e9d365ee9e
14 files changed
+20 -51

No files matched your search

-17
View File
@@ -25,23 +25,6 @@ defmodule Pinchflat.Utils.StringUtils do
|> String.slice(0..(length - 1))
end
@doc """
Truncates a string to the given length and adds `...` if the string is longer than the given length.
Will break on a word boundary. Nothing happens if the string is shorter than the given length.
Returns binary()
"""
def truncate(string, length) do
if String.length(string) > length do
string
|> String.slice(0..(length - 1))
|> String.replace(~r/\s+\S*$/, "")
|> Kernel.<>("...")
else
string
end
end
@doc """
Wraps a string in double braces. Useful as a UI helper now that
LiveView 1.0.0 allows `{}` for interpolation so now we can't use braces