I'm trying to use a label within a lightning web component. In particular it's value is something like
blah blah see <a target="_blank" href={labels.ANOTHER_LABEL}>link</a> for more information
where we are keeping the link's address in another custom label. I can't seem to get the lightning web component to recognize {labels.ANOTHER_LABEL} as a variable, it keeps trying to call it as a string literal.
I've tried both the lightning app builder and lightning web component formats from https://help.salesforce.com/s/articleView?id=sf.cl_about.htm&type=5 and neither work (the "{") doesn't get recognized as code.
{0}
or{1}
. However, embedding HTML in labels is not a good idea and certainly would not be allowed to be done in managed packages which are reviewed by Salesforce's security team since an admin could inject hacks into pages by crafting HTML that includes JavaScript. See this other Q&A for more info.String.format
. If you want to do it in JavaScript use something like this. You then use{0}
in the first label and pass the second label to the formatting function.JS
as shown here. developer.salesforce.com/docs/component-library/documentation/…