<?php
$dataHelper = $block->getDataHelper();
$storeCode = $dataHelper->getCurrentStoreCode();
$_categories = $block->getCategoryCollection($storeCode);
?>
<div id="els-category-results">
<?php if ($_categories && count($_categories)): ?>
    <div class="block block-compare result-list">
        <div class="block-title">
            <strong><?php echo __('Category Results') ?></strong>
            <span class="counter"><?php echo __('%1', count($_categories)); ?></span>
        </div>
        <div class="block-content">
            <ul>
                <?php foreach ($_categories as $_category): ?>
                    <li>
                        <a href="<?php echo $block->escapeUrl($_category['url']); ?>"
                           title="<?php echo $block->escapeHtml($_category['name']); ?>">
                            <?php echo $_category['path'] ?>
                        </a>
                    </li>
                <?php endforeach; ?>
            </ul>
        </div>
    </div>
<?php endif; ?>
</div>

<script id="els-category-results-template" type="text/x-magento-template">
    <div class="block block-compare result-list">
        <div class="block-title">
            <strong><?= __('Category Results') ?></strong>
            <span class="counter"><%= count %></span>
        </div>
        <div class="block-content">
            <ul>
                <% _.each(categories, function(doc) { %>
                    <li>
                        <a href="<%- doc.url %>"
                           title="<%- doc.name %>">
                            <%= doc.path %>
                        </a>
                    </li>
               <% }) %>
            </ul>
        </div>
    </div>
</script>
