Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using data-sly-test to create variables, prefer data-sly-set #187

Open
toniedzwiedz opened this issue Apr 6, 2020 · 0 comments
Open
Labels
htl Issues related to HTL language rule New rule or modification of existing one.

Comments

@toniedzwiedz
Copy link
Collaborator

data-sly-test had been known as the only way to assign a value to an identifier for a long time until data-sly-set was introduced for that purpose.

Valid use of data-sly-test:

<div class="foo" data-sly-test=${model.renderCondition}>
    <p>${model.text}</p>
</div>

Invalid use of data-sly-test

<sly data-sly-test.profile="${model.profile}" />
<div class="foo">
Name: ${profile.firstName}, Surname: ${profile.secondName}
</div>

Instead, data-sly-set should be used

<div class="foo" data-sly-set.profile="${model.profile}">
Name: ${profile.firstName}, Surname: ${profile.secondName}
</div>

Exception

When data-sly-test is actually used as a test condition, as well as a way to store a value?

<div class="foo" data-sly-test.profile="${model.profile}">
Name: ${profile.firstName}, Surname: ${profile.secondName}
</div>

To be discussed. This is closely related to the existing rule HTL-4 introduced in #131

@toniedzwiedz toniedzwiedz added rule New rule or modification of existing one. htl Issues related to HTL language labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
htl Issues related to HTL language rule New rule or modification of existing one.
Projects
None yet
Development

No branches or pull requests

1 participant