aemsightlyclient-library

Sightly component ignores my clientLib (doesn't include links to css)


I use example from : blogs.adobe.com but my output html file doesn't include links to my css files.

boilerplateSightlyPage.html:

<html>
<sly data-sly-include="head.html" data-sly-unwrap />
<sly data-sly-include="/libs/wcm/core/components/init/init.jsp" data-sly-unwrap />
<body>
    <div data-sly-test="${wcmmode.edit}"> 
        <!--/* Show only in edit (author) mode */-->
        <h1>Simple Page Component Using Sightly</h1>
    </div>

    <div class="flex-row"> 
        <div class="col-half">First column</div>
        <div class="col-half">Second column</div> 
    </div>

<div data-sly-resource="${@path='par',resourceType='wcm/foundation/components/parsys'}"></div>
</body>
</html>

head.html:

<head>
<meta http-equiv=”content-type” content=”text/html; charset=UTF-8” />
<sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html"
    data-sly-call="${clientlib.css @ categories='alexpi, flex'}"/>

<title>${currentPage.title}</title>
</head>

clientLib :
/etc/designs/alexpi-training/clientLib
properties:
jcr:primaryType (Name)cq:ClientLibraryFolder
categories (String[]) alexpi, flex

css.txt:

#base=css
flex.css
first.css

CSS files location:
/etc/designs/alexpi-training/clientLib/css/first.css
/etc/designs/alexpi-training/clientLib/css/flex.css

I see 'head.html' was included:

<head>
<meta http-equiv="”content-type”" content="”text/html;" charset="UTF-8”">
<title>AP empty sightly page with clienlib</title>

<link rel="stylesheet"href="/libs/cq/gui/components/authoring/clientlibs/page.css" type="text/css">
<script type="text/javascript" src="/libs/granite/author/deviceemulator/clientlibs.js"></script>
<script type="text/javascript" src="/libs/cq/gui/components/authoring/clientlibs/page.js"></script>
</head>

Solution

  • to pass an array via an option you need to use ${myVar @ optName=[myVar, 'string']} syntax, read here

    in your head.html:

    <sly data-sly-use.clientlib="/libs/granite/sightly/templates/clientlib.html"
        data-sly-call="${clientlib.css @ categories=['alexpi', 'flex']}"/>
    

    note: categories=['alexpi', 'flex']