Every Asset in a Theme supports Limited Run's Theme API and there are two main ways to use the API:
- Output -
{{ }}for things like{{ store.name }}, which will output something, likeExit Records. - Tags -
{% %}for things likeif,unless,for, andpaginate.
There are many objects that can be used to output data from your Store to your Storefront and each object's data can be output directly or sent through a filter.
A filter is structured like data, followed by a pipe, followed by the filter name and any options, like:
{{ item.published_at | date: "%B, %d %Y" }}
In the above example, the data item.published_at is piped into the date filter with the option "%B, %d %Y", which formats the date.
There are many filters available including:
asset_url
- Stylesheet Usage:
{{ 'default.css' | asset_url | stylesheet_tag: 'screen' }} - Javascript Usage:
{{ 'default.js' | asset_url | script_tag }} - Generates a
linkorscripttag for a stylesheet or javascript Theme Asset.
img_tag
- Usage:
{{ 'http://.../logo.png' | img_tag }} - Generates an
imgtag.
script_tag
- Usage:
{{ 'http://.../jquery.js' | script_tag }} - Generates a
scripttag.
stylesheet_tag
- Usage:
{{ 'http://.../main.css' | stylesheet_tag }} - Generates a
stylesheettag.
link_to
- Usage:
{{ 'Google' | link_to: 'http://google.com' }} - Generates an
atag.
link_to_javascript
- Usage:
{{ 'Alert!' | link_to_javascript: "alert('Hello, World!');" }} - Generates an
atag to inline javascript.
link_to_category
- Usage:
{{ category | link_to_category }} - This is a shortcut to generate a link to a category page, from a category object. Note this uses
{{ category.name }}and{{ category.url }}to generate a simpleatag.
link_to_download
- Usage:
{{ download | link_to_download }} - This is a shortcut to generate a link to a download, from a download object. Note this uses
{{ download.name }}to generate a specialatag that opens the download overlay.
link_to_news_item
- Usage:
{{ item | link_to_news_item }} - This is a shortcut to generate a link to a news item page, from a news item object. Note this uses
{{ news_item.title }}and{{ news_item.url }}to generate a simpleatag.
link_to_page
- Usage:
{{ page | link_to_page }} - This is a shortcut to generate a link to a page page, from a page object. Note this uses
{{ page.title }}and{{ page.url }}to generate a simpleatag.
link_to_product
- Usage:
{{ product | link_to_product }} - This is a shortcut to generate a link to a product page, from a product object. Note this uses
{{ product.name }}and{{ product.url }}to generate a simpleatag.
ordinalize
- Usage:
{{ 2 | ordinalize }} - Generates: 2nd
simple_format
- Usage: {{ product.description | simple_format }}
- Converts text broken up with line breaks into HTML paragraphs.
money
- Usage: {{ 10 | money }}
- Generates
$10.00, in your Storefront's currency.
money_with_currency
- Usage: {{ 10 | money_with_currency }}
- Generates
$10.00 USD, in your Storefront's currency.
money_without_currency
- Usage: {{ 10 | money_without_currency }}
- Generates
10.00, without any currency symbols or codes.
capitalize
- Usage: {{ 'hello there' | capitalize }}
- Generates: Hello There
downcase
- Usage: {{ 'Hello There' | downcase }}
- Generates: hello there
upcase
- Usage: {{ 'Hello There' | upcase }}
- Generates: HELLO THERE
first
- Usage: {{ store.products | first }}
last
- Usage: {{ category.products | last }}
join
- Usage: {{ product.price_range | money | join: ' - ' }}
- Generates: $10.00 - $15.00
size
- Usage: {{ category.products.size }}
- Generates: 15
Aside from filters, there are objects that can be used to access data in your Store. The objects are as follows:
- Available in all Theme Assets.
- name -
{{ store.name }}ex: Exit Records - url -
{{ store.url }}ex: http://exitrecords.limitedrun.com
- categories -
{% for category in store.categories %}…{% endfor %} - products -
{% for product in store.products %}…{% endfor %} - pages -
{% for page in store.pages %}…{% endfor %} - news -
{% for item in store.news.items %}…{% endfor %} - history -
{% for item in store.history.items %}…{% endfor %} - gallery -
{% for item in store.gallery.items %}…{% endfor %}
- Available alone, on a single category page, in the
category.htmltemplate. - Available within a for loop of
store.categories.
- name -
{{ category.name }}ex: Vinyl - slug -
{{ category.slug }}ex: vinyl - url -
{{ category.url }}ex: /categories/vinyl
- products -
{% for product in category.products %}…{% endfor %}
- Available alone, on a single product page, in the
product.htmltemplate. - Available within a for loop of
category.products.
- state -
{{ product.state }}ex: available - name -
{{ product.name }}ex: Silent Majority - Life of a Spectator - slug -
{{ product.slug }}ex: 1-silent-majority-life-of-a-spectator - description -
{{ product.description }}ex: This is a great record! - unlisted? -
{% if product.unlisted? %}Unlisted{% endif %} - announced? -
{% if product.announced? %}Announced{% endif %} - available? -
{% if product.available? %}Available{% endif %} - unavailable? -
{% if product.unavailable? %}Unavailable{% endif %} - url -
{{ product.url }}ex: /products/1-silent-majority-life-of-a-spectator - price_range -
{{ product.price_range | money | join: ' - ' }}ex: $5.00 - $10.00 - soundcloud_playlist_id -
{{ product.soundcloud_playlist_id }}ex: 0123456789 - music_catalog_number -
{{ product.music_catalog_number }}ex: EX-001 - music_pressing_information -
{{ product.music_pressing_information }}ex: 500 / White
- images -
{% for image in product.images %}…{% endfor %} - variations -
{% for variation in product.variations %}…{% endfor %} - music_track_listings -
{% for track in product.music_track_listings %}…{% endfor %}
- Available within a for loop of
product.images.
- url - Full Size
- v075_url - Max. 75px x 75px
- v150_url - Max. 150px x 150px
- v200_url - Max. 200px x 200px
- v300_url - Max. 300px x 300px
- v600_url - Max. 600px x 600px
- Available within a for loop of
product.variations.
- name
- description
- price
- weight
- requires_exact_payment
- remaining_inventory
- available?
- Available within a for loop of
product.music_track_listings.
- id3_track_number
- id3_track_artist
- id3_track_name
- Available on a single order page, in the
order.htmltemplate.
- key
- paypal_pay_key
- number
- state
- status
- attempted?
- transaction_id
- pending_reason
- customer - Customer object
- shipping_address - Address object
- item_count
- digital - Digital only?
- subtotal
- shipping
- total_price
- total_weight
- items -
{% for item in order.items %}…{% endfor %} - downloads -
{% for download in order.downloads %}…{% endfor %}
- Available within a for loop of
order.items.
- name
- digital - Digital only?
- unit_price
- unit_weight
- quantity
- total_price
- total_weight
- Available within a for loop of
order.downloads.
- name
<ul>
{% for download in order.downloads %}
<li>{{ download | link_to_download }}</li>
{% endfor %}
</ul>
- Available from an order, like
order.customer.
- first_name
- last_name
- Available from an order, like
order.shipping_address.
- first_name
- last_name
- street_address_1
- street_address_2
- city
- state
- postal_code
- country
- Available within a for loop of
store.pages.
- title
- path
- url
Note: This requires the News Module.
- Available from a store, like
store.news. - Available on the news page, in the
news.htmltemplate.
- title
- path
- url
- items
Note: This requires the News Module.
- Available alone, on a single news item page, in the
news-item.htmltemplate. - Available within a for loop of
store.news.items. - Available within a for loop of
news.items.
- title
- slug
- url
- body
- published_at
Note: This requires the History Module.
- Available from a store, like
store.history. - Available on the history page, in the
history.htmltemplate.
- title
- path
- url
- items
Note: This requires the History Module.
- Available within a for loop of
store.history.items. - Available within a for loop of
history.items.
- released_on
- released_by
- catalog_number
- name
- description
- release_information - Array of released_on, released_by and catalog_number.
- images
- links
- Available within a for loop of history items like
item.links.
- name
- url
Note: This requires the Gallery Module.
- Available from a store, like
store.gallery. - Available on the gallery page, in the
gallery.htmltemplate.
- title
- path
- url
- items
Note: This requires the Gallery Module.
- Available within a for loop of
store.gallery.items. - Available within a for loop of
gallery.items.
- url - Full Size
- v075_url - Max. 75px x 75px
- v150_url - Max. 150px x 150px
- v200_url - Max. 200px x 200px
- v300_url - Max. 300px x 300px
- v600_url - Max. 600px x 600px
There are various tags available, including:
- if
- unless
- for
- paginate
An example using if and for tags:
{% if store.pages.size > 0 %}
<h4>Info</h4>
<ul>
{% for page in store.pages %}
<li>{{ page | link_to_page }}</li>
{% endfor %}
</ul>
{% endif %}
An example of pagination:
{% paginate store.products by 30 %}
{% for product in store.products %}
<div class="product">
<a class="info" href="{{ product.url }}">
{{ product.name }} - {{ product.price_range | money | join: ' - ' }}
</a>
</div>
{% endfor %}
{{ store.products_pagination }}
{% endpaginate %}