Is there a way to get character length of a product.title and do the following

I don’t want to truncate the titles, but rather detect they run longer than a certain character length (take up two lines) and add line breaks to those that don’t so they are all the same vertical length in my slider I created.

Something like
{% if product.price.length < 50 characters %}

{{ product.title }}


{% else %}

{{ product.title }}

{% endif %}

product.price.length isn’t a thing, I know but just there to explain.

You could do this but it’s not the way I’d approach it. I would be more likely to add a css style to that title

to ensure it’s always a certain minimum height.

But if you really want to, you are quite close in your thinking:

{% if product.title.size < 50 %}

Ahh yeah I guess that too would work.

Thanks

Kinda doesn’t help the prices line up though, which my idea would have..

Guess I’ll do the easiest thing and leave it as truncated