What is the difference between sling and cq includes and when should each one be used? I kinda find both solving the same purpose. There is this link which recommends use of sling include and then there is cq doc which recommend use of cq include. As a programmer, under which situation will each of these includes be apt?
Asked
Active
Viewed 5,114 times
2 Answers
1
Usually if you are developing a CQ component, I'd follow the suggestion to use the cq:include
. The sling:include
has some additional parameter which can come handy if you need them, but I think in my 5 years as a CQ dev, I only had to use the sling:include
once.
See sling documentation for the parameter: http://sling.apache.org/documentation/bundles/sling-scripting-jsp-taglib.html#include

Thomas
- 6,325
- 4
- 30
- 65
-
Thanks for the information. Googling around led me to the same answer. – SubSul Dec 08 '14 at 09:26
-
I went through the documentation link you suggested, i think most of the attributes suggested there can be included as part of cq:include itself. Technically, when did you happen to make use of sling:include, can you pls elaborate, it'll help me understand better(newbie to cq). – SubSul Dec 08 '14 at 09:34
-
If I remember right, it was the 'replaceSelectors' attribute. But I honestly don't remember the exact use case back then. – Thomas Dec 08 '14 at 11:01
1
If you have a component that has more than one jsp,to invoke the other jsp which doesnt match up with component name , sling include is helpful having replaceselector attribute having other jsp as a value

Shishir
- 11
- 1