labels icon indicating copy to clipboard operation
labels copied to clipboard

Mark function doesn't work when capitalize filter is applied

Open lenvanessen opened this issue 7 years ago • 4 comments

Left using capitalize, right not using capitalize schermafbeelding 2017-08-29 om 15 01 30

lenvanessen avatar Aug 29 '17 13:08 lenvanessen

Yeah, most string filters output strings, not twig objects. The hacky way to do this would be {{ l('reed our creed')|striptags|capitalize }}, but then you loose the mark tags.

I don't think this will be "fixed" since this is really twig core code, and it's "working as designed"

SvanteRichter avatar Aug 29 '17 14:08 SvanteRichter

It usually makes more sense to do text-transform: uppercase; via CSS.

xiaohutai avatar Oct 30 '17 12:10 xiaohutai

@xiaohutai That'll transform the whole string, right? So not the same as |capitalize, right?

Usually capitalizing a whole string is a stylistic choice, but capitalizing the first letter is an indication of the meaning, right?

SvanteRichter avatar Nov 01 '17 21:11 SvanteRichter

@SahAssar You're right! I misinterpreted it.

There's a text-transform: capitalize in CSS, but this one is different than the one in Twig: https://twig.symfony.com/doc/2.x/filters/capitalize.html

xiaohutai avatar Nov 02 '17 08:11 xiaohutai