I have a component which has some conditional logic in it based on certain values edited by the user. To make it easier for them in some cases, I'm hoping to set one or more of those values when embedding the sub-component in another component. Something like this (though this errors out):
<sly data-sly-resource="${ @path='emailOptIn', resourceType='/apps/br/components/content/custom-forms/form-input' @type='checkbox'}"></sly>
Is that even possible? Do I have to process it via data-sly-use
and JS or Java, even if I'm not applying any business logic? Would it be better to create a separate template, rather than shoehorning too much conditional logic into this one?
Thanks in advance!
I guess the simplest way to achieve what you want would be through a Sightly template that would render what your /apps/br/components/content/custom-forms/form-input
component does now, with the added check (data-sly-test
) of your type
parameter.
<template data-sly-template.form-input="${@ type = 'defines the input type'}">
<div data-sly-test="${type == 'checkbox'}">
...
</div>
</template>
You could also process this through the Use-API. The Use-API is not built just for business logic; its purpose is to clearly separate logic from markup, whether this logic means processing some business objects or just deciding if something has to be rendered given the request's context.
TL;DR: No, you cannot pass arguments to included resources.