I have a key in my templates {sg_fs_asset_type} that typically returns a value lower cased (e.g. char). However in one of my templates I want to use this value but I would like it capitalized so Char. Is there a way to do this in my templates?
Hey Joe –
There isn’t a way to do this with the template system. You can use the {subset}
and {subset_format}
setting to regex matching within a field, but you can’t actually modify the text in the string.
You might consider a custom field on the entity that holds the capitalized version of the field value and whose value gets generated automatically (via event trigger or webhook?).
No problem I had a solution just not the most eligant. Basically I just created another template key of the same name and appended _cap on the end (e.g. sg_fs_asset_type --> sg_fs_asset_type_cap). I was already populating the original key in my work_fields on my publisher where I needed this value so I just populated the other key with the same value and capitalized it see below for the examle. Thanks Tannaz! Hope you are doing well with all this craziness!
work_fields['sg_fs_asset_type'] = fs_asset_type
work_fields['sg_fs_asset_type_cap'] = fs_asset_type.capitalize()
Ah nice, so you were able to put the logic into the publisher. That’s a great solution if you’re going to use the key in publish templates.
Hope you are doing well! Crazy times indeed.