I have a text component that is working great rendering :
{{loadATip.data.getTip.title}}
I would like to replace the line breaks, using this: {{ self.replace(’\n’, ‘ ’) }}
But I am unclear how to get the self.replace to work against the text rendered by {{loadATip.data.getTip.title}}.
What am I missing here?
Thanks!
Geoff
Does your title actually contain new lines? If you want to replace newlines inside of the title field of your getTip object, have you tried this: <h6>{{ loadATip.data.getTip.title.replace('\n', '<br />') }}</h6>?
@pmetzdorf You’re a genius!
That worked perfectly.
{{loadATip.data.getTip.title.replace(’\n’, ‘ ’)}}
Are those type of capabilities documented in the docs? I’ve spent a ton of time in the docs and never noticed that; seems like something super powerful that Retool is doing a good job of hiding… Thanks again!
Well, it’s standard Javascript. Inside the double-brackets you use Javascript, and so all standard Javascript functions / APIs are available. I don’t think Retool needs to re-explain how Javascript works, but perhaps the docs could highlight that fact a little more for those who are not familiar with the language.
Thanks @pmetzdorf for answering! Agreed @geoffrey — we should probably make it more clear that everything inside {{ }} is JS. I will add that to our to-do list. Thanks!
Hey @geoff – are you using that in a column mapper? If so, there’s an outstanding bug that incorrectly shows errors even though everything is working fine.
Are you sure that it’s incorrectly displaying errors tho? It works fine once, sure, but that’s about it. Try referencing an array (say a transformer) with currentRow value, and see that it doesn’t work when the underlying data changes. Something seems to be broken there that kills reactiveness.
@lauri Looks like you are correct about the transformers, as mappers using currentRow are only updating when the table data updates. We're looking into it and I'll update this thread with updates for either.