Home > database >  I can't get an attribute to show up in my anchor tag
I can't get an attribute to show up in my anchor tag

Time:09-04

I need to get rel="" into this html. This is part of AEM, so I have an xml file doing this:

content.xml

<rel
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
fieldDescription="HTML attribute to apply to the component."
fieldLabel="Rel"
name="./rel"/>

I've tried just duplicating how id is handled, along with a million other things...

button.html

<button 
    data-sly-use.button="com.adobe.cq.wcm.core.components.models.Button" 
    data-sly-element="${button.buttonLink.valid ? 'a' : 'button'}" 
    type="${button.buttonLink.valid ? '' : 'button'}" 
    id="${button.id}" 
    rel="${button.rel}"   <--THIS DOES NOT WORK
    
    data-sly-attribute="${button.buttonLink.htmlAttributes}" 
    aria-label="${button.accessibilityLabel}" 
    data-cmp-clickable="${button.data ? true : false}" 
    data-cmp-data-layer="${button.data.json}">
    <span data-sly-test="${button.text}" >${button.text}</span>
</button>

CodePudding user response:

this was the answer

rel=${properties.rel}

CodePudding user response:

You can use the properties object with a HTL context attribute.

 <button   
              rel=${properties.rel  @ context='attribute}
</button>
  • Related