Wrappers and functions in Quickbutik’s Mustache implementation provide essential tools for transforming and manipulating data. These helper functions extend Mustache’s capabilities for specific use cases like image optimization, translations, and asset linking.
Key Concept : Wrappers use the {{#function}}content{{/function}}
syntax to process and transform data
Available Wrappers
According to the Quickbutik platform, only the following wrappers are supported:
Wrapper Purpose Usage {{#img}}
Image manipulation and optimization {{#img}}{{product.firstimage}}_400x400{{/img}}
{{#lang}}
Text translation via Control Panel {{#lang}}My text here{{/lang}}
{{#assets}}
Link to correct path for specific file {{#assets}}css/style.css{{/assets}}
{{#breadcrumbs}}
Output breadcrumbs/category structure {{#breadcrumbs}} {{url}} {{title}} {{^last}} {{/last}} {{/breadcrumbs}}
{{#asset_flags}}
Return flag icon for language {{#asset_flags}}{{id}}{{/asset_flags}}
Image Wrapper ({{#img}}
)
The image wrapper is essential for handling product images and media optimization:
Basic Image Resizing
Product Image Gallery
Responsive Images
<!-- Resize image to specific dimensions -->
<img src="{{#img}}{{product.firstimage}}_400x400{{/img}}" alt="{{product.title}}">
<!-- Different sizes for different uses -->
<img src="{{#img}}{{product.firstimage}}_150x150{{/img}}" alt="{{product.title}}" class="thumbnail">
<img src="{{#img}}{{product.firstimage}}_800x600{{/img}}" alt="{{product.title}}" class="main-image">
Image Size Options
Size Format Description Use Case _100x100
Square thumbnail Product grid thumbnails _300x200
Landscape card Product cards, lists _400x400
Medium square Product detail thumbnails _800x600
Large landscape Product detail main image _1200x800
Extra large Lightbox, zoom functionality
Settings Home Elements Images
Home Elements with Images
{{#settings.home_elements}}
{{#element}}
{{#image1_link}}
<div class="element-image">
<img src="{{#img}}{{image1_link}}_800x400{{/img}}" alt="{{title}}">
</div>
{{/image1_link}}
{{#use_image2}}
{{#image2_link}}
<div class="element-secondary-image">
<img src="{{#img}}{{image2_link}}_400x300{{/img}}" alt="{{title}}">
</div>
{{/image2_link}}
{{/use_image2}}
{{/element}}
{{/settings.home_elements}}
Language Wrapper ({{#lang}}
)
Handle multi-language content and translations via the Control Panel:
Basic Translation
Dynamic Content Translation
Form Labels and Messages
<!-- Simple text translation -->
<h1>{{#lang}}Welcome to our store{{/lang}}</h1>
<button>{{#lang}}Add to Cart{{/lang}}</button>
<p>{{#lang}}Free shipping on orders over $50{{/lang}}</p>
Navigation and UI Translation
<!-- Translate navigation elements -->
<nav class="main-navigation">
{{#linklist.main}}
<a href="{{url}}" class="nav-link {{#current}}active{{/current}}">
{{#lang}}{{name}}{{/lang}}
</a>
{{/linklist.main}}
</nav>
<!-- Translate common UI elements -->
<div class="user-actions">
{{#shop.login_active}}
{{#user.logged_in}}
<a href="{{user.login_url}}">{{#lang}}My Account{{/lang}}</a>
{{/user.logged_in}}
{{^user.logged_in}}
<a href="{{user.login_url}}">{{#lang}}Log In{{/lang}}</a>
{{/user.logged_in}}
{{/shop.login_active}}
</div>
Assets Wrapper ({{#assets}}
)
Link to correct paths for theme files like CSS, JavaScript, and other assets:
CSS and JavaScript Assets
Image and Font Assets
Icon and Resource Assets
<!-- Link to theme CSS files -->
<link rel="stylesheet" href="{{#assets}}css/style.css{{/assets}}">
<link rel="stylesheet" href="{{#assets}}css/responsive.css{{/assets}}">
<!-- Link to theme JavaScript files -->
<script src="{{#assets}}js/main.js{{/assets}}"></script>
<script src="{{#assets}}js/cart.js{{/assets}}"></script>
Breadcrumbs Wrapper ({{#breadcrumbs}}
)
Output breadcrumbs/category structure regardless of the current page:
Basic Breadcrumbs
Styled Breadcrumbs
Breadcrumbs with Icons
<!-- Simple breadcrumb navigation -->
<nav class="breadcrumbs">
{{#breadcrumbs}}
<a href="{{url}}">{{title}}</a>
{{^last}} > {{/last}}
{{/breadcrumbs}}
</nav>
Breadcrumb Properties
Within the {{#breadcrumbs}}
loop:
Property Type Description url
String Link URL for the breadcrumb item title
String Display text for the breadcrumb item last
Boolean True if this is the last (current) breadcrumb item
Asset Flags Wrapper ({{#asset_flags}}
)
Return flag icons for languages (used within the languages loop):
Language Selector with Flags
Compact Language Switcher
Language Dropdown
{{#shop.app.languages}}
<div class="language-selector">
<h4>{{#lang}}Choose Language{{/lang}}</h4>
{{#shop.languages}}
<a href="{{url}}" class="language-option">
<img src="{{#asset_flags}}{{id}}{{/asset_flags}}"
alt="{{id}}"
class="flag">
{{id}}
</a>
{{/shop.languages}}
</div>
{{/shop.app.languages}}
Combining Wrappers
Complete Examples with Multiple Wrappers
Product Card with All Wrappers
Complete Page Template
<div class="product-card">
<!-- Product image with optimization -->
<div class="product-image">
{{#product.firstimage}}
<img src="{{#img}}{{product.firstimage}}_300x300{{/img}}" alt="{{product.title}}">
{{/product.firstimage}}
{{^product.firstimage}}
<img src="{{#assets}}images/no-image.png{{/assets}}" alt="{{#lang}}No image available{{/lang}}">
{{/product.firstimage}}
</div>
<!-- Product information with translations -->
<div class="product-info">
<h3>{{product.title}}</h3>
<p class="price">{{product.price}}</p>
{{#product.soldOut}}
<span class="status out-of-stock">{{#lang}}Out of Stock{{/lang}}</span>
{{/product.soldOut}}
{{^product.soldOut}}
<button class="add-to-cart">{{#lang}}Add to Cart{{/lang}}</button>
{{/product.soldOut}}
</div>
</div>
Best Practices
Image Optimization Always use the {{#img}}
wrapper with appropriate dimensions for optimal performance
Translation Consistency Wrap all user-facing text with {{#lang}}
for proper multi-language support
Asset Management Use {{#assets}}
for all theme files to ensure correct paths across environments
Breadcrumb Navigation Implement breadcrumbs for better user navigation and SEO benefits
Common Patterns
Error Handling and Fallbacks
Image Fallbacks
Content Fallbacks
<!-- Product image with fallback -->
{{#product.firstimage}}
<img src="{{#img}}{{product.firstimage}}_400x400{{/img}}" alt="{{product.title}}">
{{/product.firstimage}}
{{^product.firstimage}}
<img src="{{#assets}}images/placeholder.jpg{{/assets}}" alt="{{#lang}}No image available{{/lang}}">
{{/product.firstimage}}
Next Steps