All files / src/defaults _generated.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 0/0
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 1902x                                                                                                                                                                                                       2x                                                                                                                                                                                  
export const defaultLiquidTemplate = `
{% assign hasKeywords = response.keywords.hits.length > 0 %}
{% assign hasProducts = response.products.hits.length > 0 %}
{% assign hasHistory = history.length > 0 %}
{% assign imagePlaceHolder = 'https://cdn.nosto.com/nosto/9/mock' %}
 
<div class="ns-autocomplete-results">
  {% if hasKeywords == false and hasProducts == false and hasHistory %}
    <div class="ns-autocomplete-history">
      <div class="ns-autocomplete-header">
        Recently searched
      </div>
      {% for hit in history %}
        <div class="ns-autocomplete-history-item" data-ns-hit="{{ hit | json | escape }}" data-testid="history">
          {{ hit.item }}
          <a
            href="#"
            class="ns-autocomplete-history-item-remove"
            data-ns-remove-history="{{hit.item}}">
            &#x2715;
          </a>
        </div>
      {% endfor %}
    </div>
    <div class="ns-autocomplete-history-clear">
      <button
        type="button"
        class="ns-autocomplete-button"
        data-ns-remove-history="all">
        Clear history
      </button>
    </div>
  {% elsif hasKeywords or hasProducts %}
    {% if hasKeywords %}
      <div class="ns-autocomplete-keywords">
        <div class="ns-autocomplete-header">
          Keywords
        </div>
        {% for hit in response.keywords.hits %}
          <div class="ns-autocomplete-keyword" data-ns-hit="{{ hit | json | escape }}" data-testid="keyword">
            {% if hit._highlight and hit._highlight.keyword %}
              <span>{{ hit._highlight.keyword }}</span>
            {% else %}
              <span>{{ hit.keyword }}</span>
            {% endif %}
          </div>
        {% endfor %}
      </div>
    {% endif %}
    {% if hasProducts %}
      <div class="ns-autocomplete-products">
        <div class="ns-autocomplete-header">
          Products
        </div>
        {% for hit in response.products.hits %}
          <a
            class="ns-autocomplete-product"
            href="{{ hit.url }}"
            data-ns-hit="{{ hit | json | escape }}"
            data-testid="product">
            <img
              class="ns-autocomplete-product-image"
              src="{% if hit.imageUrl %}{{ hit.imageUrl }}{% else %}{{ imagePlaceHolder }}{% endif %}"
              alt="{{ hit.name }}"
              width="60"
              height="40" />
            <div class="ns-autocomplete-product-info">
              {% if hit.brand %}
                <div class="ns-autocomplete-product-brand">
                  {{ hit.brand }}
                </div>
              {% endif %}
              <div class="ns-autocomplete-product-name">
                {{ hit.name }}
              </div>
              <div>
                <span>
                  {{ hit.price }}&euro;
                </span>
                {% if hit.listPrice and hit.listPrice != hit.price %}
                    <span class="ns-autocomplete-product-list-price">
                        {{ hit.listPrice }}
                        &euro;
                    </span>
                {% endif %}
              </div>
            </div>
          </a>
        {% endfor %}
      </div>
    {% endif %}
    <div class="ns-autocomplete-submit">
      <button type="submit" class="ns-autocomplete-button">
        See all search results
      </button>
    </div>
  {% endif %}
</div>
`
 
export const defaultMustacheTemplate = `
<div class="ns-autocomplete-results">
  {{#response.keywords.hits.length}}
    <div class="ns-autocomplete-keywords">
      <div class="ns-autocomplete-header">
        Keywords
      </div>
      {{#response.keywords.hits}}
        <div class="ns-autocomplete-keyword" data-ns-hit="{{toJson}}" data-testid="keyword">
          {{#_highlight.keyword}}
            <span>{{{.}}}</span>
          {{/_highlight.keyword}}
          {{^_highlight.keyword}}
            <span>{{keyword}}</span>
          {{/_highlight.keyword}}
        </div>
      {{/response.keywords.hits}}
    </div>
  {{/response.keywords.hits.length}}
 
  {{#response.products.hits.length}}
    <div class="ns-autocomplete-products">
      <div class="ns-autocomplete-header">
        Products
      </div>
      {{#response.products.hits}}
        <a class="ns-autocomplete-product" href="{{url}}" data-ns-hit="{{toJson}}" data-testid="product">
          <img
              class="ns-autocomplete-product-image"
              src="{{#imageUrl}}{{ imageUrl }}{{/imageUrl}}{{^imageUrl}}{{ imagePlaceholder }}{{/imageUrl}}"
              alt="{{name}}"
              width="60"
              height="40"
          />
          <div class="ns-autocomplete-product-info">
            {{#brand}}
              <div class="ns-autocomplete-product-brand">
                {{.}}
              </div>
            {{/brand}}
            <div class="ns-autocomplete-product-name">
              {{name}}
            </div>
            <div>
              <span>
                {{price}}&euro;
              </span>
              {{#showListPrice}}
                <span class="ns-autocomplete-product-list-price">
                  {{listPrice}}&euro;
                </span>
              {{/showListPrice}}
            </div>
          </div>
        </a>
      {{/response.products.hits}}
    </div>
  {{/response.products.hits.length}}
 
  {{#history.length}}
    <div class="ns-autocomplete-history">
      <div class="ns-autocomplete-header">
        Recently searched
      </div>
      {{#history}}
        <div class="ns-autocomplete-history-item" data-ns-hit="{{toJson}}" data-testid="history">
          {{item}}
          <a href="#" class="ns-autocomplete-history-item-remove" data-ns-remove-history="{{item}}">
            &#x2715;
          </a>
        </div>
      {{/history}}
    </div>
    <div class="ns-autocomplete-history-clear">
      <button type="button" class="ns-autocomplete-button" data-ns-remove-history="all">
        Clear history
      </button>
    </div>
  {{/history.length}}
 
  {{#response.keywords.hits.length}}{{#response.products.hits.length}}
    <div class="ns-autocomplete-submit">
      <button type="submit" class="ns-autocomplete-button">
        See all search results
      </button>
    </div>
  {{/response.products.hits.length}}{{/response.keywords.hits.length}}
</div>
`