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'}