Answer the question
In order to leave comments, you need to log in
What is a template engine?
A piece of code from the Shopify Online Store system. Code inside the spoiler:
{% assign number_of_related_products_to_show = 4 %}
{% assign image_size = 'compact' %}
{% assign heading = 'Other fine products' %}
{% capture number_of_related_products_to_fetch %}{{ number_of_related_products_to_show | plus: 1 }}{% endcapture %}
{% if collection == null or collection.handle == 'frontpage' or collection.handle == 'all' %}
{% assign found_a_collection = false %}
{% for c in product.collections %}
{% if found_a_collection == false and c.handle != 'frontpage' and c.handle != 'all' and c.all_products_count > 1 %}
{% assign found_a_collection = true %}
{% assign collection = c %}
{% endif %}
{% endfor %}
{% endif %}
<div class="widget_related_products">
{% if collection and collection.products_count > 1 %}
<h3>{{ heading }}</h3>
<div class="widget_content">
<ul class="clearfix product_listing_main product_listing_related">
{% assign current_product_found = false %}
{% for prod in collection.products limit: number_of_related_products_to_fetch %}
{% if prod.title == product.title %}
{% assign current_product_found = true %}
{% else %}
{% unless current_product_found == false and forloop.last %}
<li class="wow col-sm-3 product product__{% cycle 'counter': '1','2','3','4' %}">
<div class="prod_inside clearfix">
<div class="product_img">
<a href="{{ prod.url | within: collection }}" title="{{ prod.title | escape }}"><img src="{{ prod.featured_image | product_img_url: image_size }}" alt="{{ prod.title | escape }}" /></a>
</div>
<div class="product_info">
<div class="product_price"><span class="money">{{ prod.price | money }}</span></div>
<div class="product_name"><a href="{{ prod.url }}" title="{{ prod.title | escape }}">{{ prod.title | truncate:20 }}</a></div>
</div>
</div>
</li>
{% endunless %}
{% endif %}
{% endfor %}
</ul>
</div>
{% endif %}
</div>
Answer the question
In order to leave comments, you need to log in
It's some kind of template. Similar to Twig but uses set
instead of assign
.
This is PHP templating markup (however, other languages/platforms also use them, like Python/Django). At first glance Twig , but maybe some other.
Still similar to Jinja2. But since I haven't really used it, I'm not sure. I think it's enough to drive the names of a pair of tags into the search bar of any search engine in order to get the answer with the first link.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question