Expand my Community achievements bar.

SOLVED

Anchor tag ada issue - Richtext component

Avatar

Level 2

Hi Team,

 

This anchor field is generating the markup in the form:  <a  id = "name provided through authoring field"></a> - out of box behaviour of aem rich text component

Its throwing some ada compliance issue.

is there way to change a tag to span tag.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Yes, in Sling Model, you can do something like this:

@Model(adaptables=Resource.class)
public class MyTextComponent {

    @Optional
    @ValueMapValue
    @default(values = "")
    private String text;

    private String richText;

    @PostConstruct
    protected void init() {
        if (!text.isEmpty()) {
            richText = text.replaceAll("</?span>", "");
        }
    }

    public String getRichText() {
        return richText;
    }
}

in Sightly you can just call ${model.richText @ context='html'} 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Yes, in Sling Model, you can do something like this:

@Model(adaptables=Resource.class)
public class MyTextComponent {

    @Optional
    @ValueMapValue
    @default(values = "")
    private String text;

    private String richText;

    @PostConstruct
    protected void init() {
        if (!text.isEmpty()) {
            richText = text.replaceAll("</?span>", "");
        }
    }

    public String getRichText() {
        return richText;
    }
}

in Sightly you can just call ${model.richText @ context='html'}