Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using vue.js in Shopify liquid templates

This should be simple but despite searching I was unable to find any solution to this. How do you use vue template tags within a liquid file? Since both Vue and liquid use the same curly brackets, I'm unable to render any of my view data:

<img src="{{ product.featured_image }}" />

results in:

<img src>

There are 36 products in my parent view component.

When I try to use custom delimiters:

new Vue({
  delimiters: ['@{{', '}}'],

It won't parse with Vue:

  GET https://inkkas.com/collections/@ 404 (Not Found)

UPDATE: I'm able to access Vue data with v-bind: but I still need to be able to use delimiters also.

like image 364
Kevin Compton Avatar asked Apr 19 '17 20:04

Kevin Compton


1 Answers

Apparently with Shopify, you can't put these delimiters in the tag attributes at all so for those use v-bind: (the shorthand won't work). Also you have to use a single curly brace for your custom delimiter or it will still try to parse with liquid, for example:

delimiters: ['${', '}']

will work with:

<span class="title">${ product.title }</span>
like image 86
Kevin Compton Avatar answered Sep 21 '22 05:09

Kevin Compton