Search code examples
javascriptmustache

Is it possible to do something like beforeall with mustache?


I have the following template:

<div class="photoList">
    {{#photos}}
        <img src="{{columnPhoto.url}}" data-zoom-url="{{original_size.url}}"/>
    {{/photos}}
</div>

Sometimes {{#photos}} is empty or not set, in those cases, I don't want to add the div .photolist, is this possible?


Solution

  • {{#photos.length}}
    <div class="photoList">
        {{#photos}}
            <img src="{{columnPhoto.url}}" data-zoom-url="{{original_size.url}}"/>
        {{/photos}}
    </div>
    {{/photos.length}}