HTL Use-API

HTL Use-API

Use-API provides an easy way of binding logic to the template elements. Use-API's can be written in Java or JavaScript or both. Business logic is written Java, view-specific logic can be written in server-side executed JavaScript.

Sample : Pass in parameters from components.

<div data-sly-use.myClass="${'com.myproject.components.MyTestComponent' @ firstName='John', lastName='Miller'}">
    ${myClass.fullname}
</div>


import com.adobe.cq.sightly.WCMUsePojo;
public class MyTestComponent extends WCMUsePojo {
    // Combine the firstName and lastName
    public String getFullname() {
        return get("firstName", String.class) + " " + get("lastName", String.class);
    }
}


Go to HTL Tutorial Home page

No comments:

Post a Comment