1

I'm using the aura:unescapedHtml component with some custom labels that will also include markup. For example:

Custom Label:

<labels>
    <fullName>Register_Text</fullName>
    <language>en_US</language>
    <value>&lt;a href="/register"&gt;Click here&lt;/a&gt; to finish.</value>
</labels>

Lightning component:

<aura:unescapedHtml value="{!$Label.c.Register_Text}" />

I have a scenario where the text I wanted to add to custom label includes a value from an aura:attribute in the Lightning component:

<aura:attribute name="registerLink" type="String"/>

<a href="{!v.registerLink}">Click here</a> to finish

If I add that href markup to a custom label, will it still render when referenced in <aura:unescapedHtml>?

<labels>
    <fullName>Register_Text</fullName>
    <language>en_US</language>
    <value>&lt;a href="{!v.registerLink}"&gt;Click here&lt;/a&gt; to finish</value>
</labels>

1 Answer 1

1

No, that won't work. However, there is a format expression for your use case.

<aura:unescapedHtml value="{!format($Label.c.Register_Text,v.registerLink)}"/>

And from there, you just need to use a placeholder:

<labels>
    <fullName>Register_Text</fullName>
    <language>en_US</language>
    <value>&lt;a href="{0}"&gt;Click here&lt;/a&gt; to finish</value>
</labels>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .