Download tasks/llbean/environment/reference/clone/frontend/templates/_macros.html from TIGER-Lab/WebsiteBench: direct link, hf CLI and curl.
- Browser
- Download file 6.93 kB
-
https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/llbean/environment/reference/clone/frontend/templates/_macros.html
- Command line
-
hf download hf://datasets/TIGER-Lab/WebsiteBench/tasks/llbean/environment/reference/clone/frontend/templates/_macros.html
-
curl -L -o _macros.html https://huggingface.co/datasets/TIGER-Lab/WebsiteBench/resolve/main/tasks/llbean/environment/reference/clone/frontend/templates/_macros.html
6.93 kB
| {# | |
| Shared fragments. The product card reproduces the source | |
| .ProductThumbnail_container contract recorded in scope/notes/02-recon-plp.md. | |
| #} | |
| {% macro stars(rating) %} | |
| <span class="Rating_ratings Rating_small" aria-label="Rating: {{ '%.1f'|format(rating or 0) }} out of 5 stars"> | |
| <span class="Rating_top" style="width: {{ ((rating or 0) / 5 * 100)|round(2) }}%"><i>★</i><i>★</i><i>★</i><i>★</i><i>★</i></span> | |
| <span class="Rating_bottom"><i>★</i><i>★</i><i>★</i><i>★</i><i>★</i></span> | |
| </span> | |
| {% endmacro %} | |
| {% macro price_block(product) %} | |
| <div class="ProductThumbnail_price"> | |
| {% if product.price_low != product.price_high %} | |
| <span class="screenreader">Price range from: ${{ '%.2f'|format(product.price_low) }} to: ${{ '%.2f'|format(product.price_high) }}</span> | |
| <span class="sale">${{ '%.2f'|format(product.price_low) }}</span>-<span>${{ '%.2f'|format(product.price_high) }}</span> | |
| {% else %} | |
| <span class="screenreader">Price: ${{ '%.2f'|format(product.price_low) }}</span> | |
| <span>${{ '%.2f'|format(product.price_low) }}</span> | |
| {% endif %} | |
| </div> | |
| {% endmacro %} | |
| {% macro product_card(product) %} | |
| <li class="ProductThumbnail_container"> | |
| <div class="ProductThumbnail_wrapper"> | |
| <div class="ProductThumbnail_product"> | |
| <a href="/llb/shop/{{ product.product_id }}{% if product.slug %}?page={{ product.slug }}{% endif %}"> | |
| <img src="{{ product.grid_image }}" width="302" height="352" loading="lazy" | |
| alt="{{ product.grid_image_alt }}"> | |
| </a> | |
| </div> | |
| </div> | |
| {% if product.colors %} | |
| <div class="ColorSwatches_wrapper"> | |
| <div class="ColorSwatches_swatch-list"> | |
| <fieldset> | |
| <legend class="screenreader">Colors</legend> | |
| <ul class="ColorSwatches_list-container"> | |
| {% for color in product.colors[:6] %} | |
| <li title="{{ color.name }}"> | |
| <a href="/llb/shop/{{ product.product_id }}?color={{ color.name|urlencode }}" | |
| aria-label="{{ color.name }}, color {{ loop.index }} of {{ product.colors|length }}"> | |
| {% if color.swatch %}<img src="{{ color.swatch }}" width="18" height="18" alt="{{ color.name }}"> | |
| {% else %}<span class="ColorSwatches_dot" data-color="{{ color.bucket or 'Other' }}"></span>{% endif %} | |
| </a> | |
| </li> | |
| {% endfor %} | |
| </ul> | |
| </fieldset> | |
| </div> | |
| </div> | |
| {% endif %} | |
| <a class="ProductThumbnail_name Anchor_not-underlined Anchor_anchor" | |
| href="/llb/shop/{{ product.product_id }}{% if product.slug %}?page={{ product.slug }}{% endif %}">{{ product.name }}</a> | |
| {{ price_block(product) }} | |
| {% if product.color_count %} | |
| <div class="ProductThumbnail_color-count">{{ product.color_count }} colors available</div> | |
| {% endif %} | |
| {{ stars(product.rating) }} | |
| <a class="Rating_count Anchor_anchor" href="/llb/shop/{{ product.product_id }}#reviews">{{ product.review_count }}</a> | |
| </li> | |
| {% endmacro %} | |
| {% macro product_grid(items) %} | |
| <ul class="ProductThumbnailList_list"> | |
| {% for product in items %}{{ product_card(product) }}{% endfor %} | |
| </ul> | |
| {% endmacro %} | |
| {# | |
| The panel renders only the facets the source shows for this collection, in the | |
| source's order. Every facet here filters against real local data, so no control | |
| is inert. | |
| #} | |
| {% macro checkbox_group(title, name, options, selected) %} | |
| {% if options %} | |
| <div class="Filter_group"> | |
| <h3>{{ title }}</h3> | |
| {% for opt in options %} | |
| <label class="Filter_option"> | |
| <input type="checkbox" name="{{ name }}" value="{{ opt.name }}" {% if opt.name in selected %}checked{% endif %}> | |
| {% if name == 'color' %}<span class="ColorSwatches_dot" data-color="{{ opt.name }}"></span>{% endif %} | |
| {{ opt.name }} ({{ opt.count }}) | |
| </label> | |
| {% endfor %} | |
| </div> | |
| {% endif %} | |
| {% endmacro %} | |
| {% macro facet_panel(facets, selected, sort_options, action, hidden) %} | |
| <form class="FilterNavigation_panel" method="get" action="{{ action }}"> | |
| {% for key, value in (hidden or {}).items() %}<input type="hidden" name="{{ key }}" value="{{ value }}">{% endfor %} | |
| <h2 class="Filters_heading">Filter By:</h2> | |
| <div class="Filter_group"> | |
| <h3>Sort</h3> | |
| <select name="sort_field" class="SortOptions_select" aria-label="Sort"> | |
| {% for key, label in sort_options.items() %} | |
| <option value="{{ key }}" {% if selected.sort_field == key %}selected{% endif %}>{{ label }}</option> | |
| {% endfor %} | |
| </select> | |
| </div> | |
| {% for key in facets.order %} | |
| {% if key == 'percent_off' %} | |
| {{ checkbox_group('% Off', 'percent_off', facets.percent_off, selected.percent_off) }} | |
| {% elif key == 'sale' and facets.sale %} | |
| <div class="Filter_group"> | |
| <h3>Sale</h3> | |
| <label class="Filter_option"> | |
| <input type="checkbox" name="sale" value="1" {% if selected.sale %}checked{% endif %}> | |
| Sale ({{ facets.sale.count }}) | |
| </label> | |
| </div> | |
| {% elif key == 'new' and facets.new %} | |
| <div class="Filter_group"> | |
| <h3>New Arrivals</h3> | |
| <label class="Filter_option"> | |
| <input type="checkbox" name="new" value="1" {% if selected.new %}checked{% endif %}> | |
| New Arrivals ({{ facets.new.count }}) | |
| </label> | |
| </div> | |
| {% elif key == 'gender' %} | |
| {{ checkbox_group('Gender', 'gender', facets.gender, selected.gender) }} | |
| {% elif key == 'size' %} | |
| {{ checkbox_group('Size', 'size', facets.size, selected.size) }} | |
| {% elif key == 'material' %} | |
| {{ checkbox_group('Material', 'material', facets.material, selected.material) }} | |
| {% elif key == 'color' %} | |
| {{ checkbox_group('Color', 'color', facets.color, selected.color) }} | |
| {% elif key == 'price' %} | |
| {{ checkbox_group('Price', 'price', facets.price, selected.price) }} | |
| {% elif key == 'brand' %} | |
| {{ checkbox_group('Brand', 'brand', facets.brand, selected.brand) }} | |
| {% endif %} | |
| {% endfor %} | |
| <div class="Filter_actions"> | |
| <button class="Button_buttonComponent Button_primary" type="submit">Apply Filters</button> | |
| <a class="Filter_clear" href="{{ action }}">Clear All</a> | |
| </div> | |
| </form> | |
| {% endmacro %} | |
| {% macro load_more(batch, action, params) %} | |
| {% if batch.has_more %} | |
| <form class="ProductThumbnailList_more" method="get" action="{{ action }}"> | |
| {% for key, value in params.items() %} | |
| {% if value is iterable and value is not string %} | |
| {% for entry in value %}<input type="hidden" name="{{ key }}" value="{{ entry }}">{% endfor %} | |
| {% else %}<input type="hidden" name="{{ key }}" value="{{ value }}">{% endif %} | |
| {% endfor %} | |
| <input type="hidden" name="start" value="{{ batch.next_start }}"> | |
| <input type="hidden" name="viewCount" value="{{ batch.view_count }}"> | |
| <input type="hidden" name="isLoadMore" value="true"> | |
| <button class="Button_buttonComponent Button_primary Button_large" type="submit">LOAD {{ [batch.view_count, batch.remaining]|min }} MORE</button> | |
| </form> | |
| {% endif %} | |
| {% endmacro %} | |