how to truncate string in rendering varitant field

Sitecore 9.1

 Sitecore SXA has a field type call Template, we can use it turncate string when necessary.

#set ($text = $item.ListingTitle)

#if ($text.Length > 100)
$text.Substring(0, 100)...
#else
$text
#end

To use Template field, make sure the field name doesn't has speace.

Reference - https://doc.sitecore.com/developers/sxa/18/sitecore-experience-accelerator/en/create-a-rendering-variant.html

Another way is create a view rendering and use Component Field. - Component Field will cause the page hang in Mobile or other device, except desktop. DON'T Use.