Crowd Cow Liquid Reference

Complete guide to Liquid templating in Contentful longText sections. Liquid docs

Setup

Create a Contentful longText entry with format: html and newStyle: true. Add it to any page's sections array. HTML containing {% or {{ is automatically processed as Liquid.

Tailwind CSS classes work inside shadow DOM islands. Any class used must be in app/assets/tailwind/.safelist.

Global Objects

collections

Access product collections by token. Returns a collection object with .products, .title, and .url.

{% assign products = collections["TOKEN"].products %}
{% for product in products limit:6 %}
  {{ product.title }} — {{ product.price }}
{% endfor %}

{{ collections["TOKEN"].title }}
{{ collections["TOKEN"].url }}

Products are filtered by visitor's FC (only shippable items) and exclude out-of-stock. Max 24 per collection. Use limit and offset on the for loop.

customer

Current visitor context. Use for personalization.

FieldTypeDescription
customer.logged_inbooleanTrue if authenticated customer (not placeholder)
customer.subscriberbooleanTrue if active subscription
customer.first_namestringFirst name (empty if unknown)
customer.emailstringEmail (empty for placeholder/guest users)
{% if customer.subscriber %}
  Welcome back, {{ customer.first_name }}! Subscriber pricing applied.
{% elsif customer.logged_in %}
  Hey {{ customer.first_name }}, subscribe and save 5%!
{% else %}
  Sign up for exclusive deals.
{% endif %}

Product Fields

Each product in a collection loop exposes these fields. All text fields are HTML-escaped. Fields are lazy — only computed when accessed.

Display

FieldTypeExample
titlestring"Wagyu Ribeye"
descriptionHTMLRich text from admin (unescaped)
permalinkstring/products/wagyu-ribeye?offer=xxx
farm_namestring"Snake River Farms"
weight_textstring"1.5 lbs"
highlight_textstring"20% Off"
why_we_sourced_itstringPlain text (HTML stripped from admin content)

Images

FieldDescription
image_rawBase URL — use with imgix filter for custom sizes
image_urlPre-sized 720x720
image_url_smallPre-sized 300x300

Pricing

FieldTypeNotes
pricestringFormatted for current user: "$89.99"
price_centsintegerUse with money filter: {{ product.price_cents | money }}
member_price / member_price_centsstring / intSubscriber price
non_member_price / non_member_price_centsstring / intNon-subscriber price
list_price / list_price_centsstring / intMSRP / strikethrough price
discount_percentintegere.g. 20 for 20% off
member_benefit_eligiblebooleanWhether subscriber pricing applies

Stock & Ratings

FieldType
in_stock / sold_outboolean
stock_quantityinteger
ratingfloat (e.g. 4.5)
rating_countinteger

Rendered Components

FieldDescription
add_to_cart_buttonFull working ATC form with CSRF, loading state, turbo
price_componentMember/non-member price display component
star_ratingStar SVGs with numeric rating

Tokens

FieldDescription
tokenBid item token (for cart operations)
product_tokenProduct token

Custom Filters

imgix

Resize any image URL via imgix CDN. Auto-compresses and formats.

{{ product.image_raw | imgix: 800, 600 }}          width, height (default crop)
{{ product.image_raw | imgix: 400, 400, "fill" }}    custom fit mode
{{ "https://example.com/img.jpg" | imgix: 1200 }}    works on any URL

image_tag

Generate a full <img> tag with imgix src, lazy loading, dimensions, and alt text.

{{ product.image_raw | image_tag: 480, 480, "Product photo", "w-full rounded-xs" }}

Outputs:
<img src="[imgix url]" alt="Product photo" loading="lazy" width="480" height="480" class="w-full rounded-xs" />

money

Format cents as dollars.

{{ 8999 | money }}                  → $89.99
{{ product.price_cents | money }}    → $129.99

experiment

Check A/B test variant for current visitor. Returns "experimental", "control", or nil.

{% assign variant = "exp-cc-my-test" | experiment %}
{% if variant == "experimental" %}
  Show new design
{% else %}
  Show control
{% endif %}

Special Collection Tokens

Besides regular collection tokens (find in admin at /admin/product_collections), these special tokens are available:

TokenDescription
purchase_historyPersonalized — based on visitor's past orders
best_sellersSite-wide best sellers
weekly_dealsCurrent weekly deals
beef, chicken, etc.Protein category feeds

Tailwind CSS

Only safelisted Tailwind classes work in Liquid templates. The safelist is at app/assets/tailwind/.safelist.

If a class doesn't render: add it to the safelist and rebuild with bundle exec rake tailwind:build.

Responsive prefixes (e.g. md:flex-row-reverse) each need their own safelist entry — they're separate CSS rules.

Customer Context

LOGGED IN
No
SUBSCRIBER
Not a subscriber
FIRST NAME
EMAIL
PREMIUM MEATS DELIVERED
The Crowd Cow Difference

Hand-selected cuts from independent farms. Subscribe and save 5% on every order.

Start Your Subscription

Money Filter

Beef Burger Patties 1/3 lb
$25.98 List: $25.98
Premium Ground Beef
$29.98 List: $29.98
Premium Ground Bison
$25.00 List: $25.00

image_tag Filter

Generates a full <img> with lazy loading, dimensions, and alt text.

Beef Burger Patties 1/3 lb
Beef Burger Patties 1/3 lb
Premium Ground Beef
Premium Ground Beef
Premium Ground Bison
Premium Ground Bison

imgix Filter — Custom Sizes

100×100
200×200
300×200
400×200 fill

Collection Metadata

TITLE
HP - Ground Meat (Main Page)
URL
https://www.crowdcow.mom/products/ground-meat

Experiment / A/B Test

Use the experiment filter to check which variant a user is in:

{% assign variant = "exp-cc-my-test" | experiment %}
{% if variant == "experimental" %}
  Show new design
{% else %}
  Show control
{% endif %}

Returns the user's variant ("experimental", "control") or nil if not in the experiment.

Full Product Cards

Beef Burger Patties 1/3 lb
Beef Burger Patties 1/3 lb
Little Belt Cattle Co.
$25.98
2 lbs
Premium Ground Beef
Premium Ground Beef
Certified Piedmontese
$29.98
2 lbs
Premium Ground Bison
Premium Ground Bison
Fossil Farms
$25.00
1lb
Wagyu Burger Patties 1/2 lb
Wagyu Burger Patties 1/2 lb
Mishima Reserve
$29.98
2 lbs
Hot Dogs
Hot Dogs
Thousand Hills Lifetime Grazed
$23.98
1.25 lbs
Heirloom Ground Chicken
Heirloom Ground Chicken
Mary's Heirloom Chicken
$21.98
2 lbs