Netcentric / aem-htl-style-guide

A style guide for the HTML Template Language (HTL), the templating language use by the Adobe Experience Manager (AEM).
MIT License
138 stars 50 forks source link

Update HTL Guide with latest developments #28

Closed paulochang closed 4 months ago

paulochang commented 4 years ago

HTL Spec was updated in June 2018 to support variable setting via data-sly-set (https://github.com/adobe/htl-spec/blob/1.4/SPECIFICATION.md#2212-set) and available in AEM 6.5 (https://docs.adobe.com/content/help/en/experience-manager-65/release-notes/sites.html), AEM 6.3 SP3 and AEM 6.4 SP1 (https://github.com/adobe/htl-spec).

This potentially means we should now recommend the usage of data-sly-set when possible.

We should probably also mention that setting up variables by abusing the data-sly-test.identifier pattern for cases other than test blocks is to be avoided when possible.(https://github.com/Netcentric/aem-htl-style-guide#4.5).

karollewandowski commented 4 years ago

This potentially means we should now recommend the usage of data-sly-set when possible.

I would rather say: only when absolutely needed.

paulochang commented 4 years ago

An example of data-sly-test abusing can be found here: https://github.com/adobe/aem-core-wcm-components/issues/878

kwin commented 4 years ago

@paulochang I agree, can you come up with a PR? I guess we should clarify https://github.com/Netcentric/aem-htl-style-guide#4.5

paulochang commented 4 years ago

Yes, I will try to come up with either a rewording or clarification of the rule.

@karollewandowski could you clarify what you think should be avoided so I can incorporate your comment?

karollewandowski commented 4 years ago

I meant overusing it for defining variables for very simple cases like:

<sly data-sly-set.details="${product.details}"></sly>
${details.name}
${details.price}
<!-- product is not used anymore after those 2 usages above -->

I think that such code should be preferred:

${product.details.name}
${product.details.price}

So in cases when set result is used for defining variables for expressions that are very cheap and used very few times. Maybe it is too obvious to mention it in the rules. I just wouldn't use words "when possible" to avoid spreading such overusing.

paulochang commented 5 months ago

It just took me a few years! Please check my pr @kwin @karollewandowski