Closed ttnbtfy closed 11 months ago
Fixed by Liquid 2.2.1
Note: ST's JSON syntax is not optimized to work with templating engines. Thus there might still be some smaller highlighting issues, like illegal highlighted commas etc.
It looks a lot more comfortable but still seems unfinished, I thought I should give you this code:
<script type="application/ld+json">
{
"@context": "http://schema.org/",
"@type": "Product",
"name": {{ product.title | json }},
"url": {{ shop.url | append: product.url | json }},
{%- if selected_product.featured_media -%}
{%- assign media_size = selected_product.featured_media.preview_image.width -%}
"image": [
{{ selected_product.featured_media | image_url: width: media_size | prepend: "https:" | json }}
],
{%- endif -%}
"description": {{ product.description | strip_html | json }},
{%- if selected_product.sku != blank -%}
"sku": {{ selected_product.sku | json }},
{%- endif -%}
"brand": {
"@type": "Thing",
"name": {{ product.vendor | json }}
},
"offers": [
{%- for variant in product.variants -%}
{
"@type" : "Offer",
{%- if variant.sku != blank -%}
"sku": {{ variant.sku | json }},
{%- endif -%}
"availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}",
"price" : {{ variant.price | divided_by: 100.00 | json }},
"priceCurrency" : {{ cart.currency.iso_code | json }},
"url" : {{ shop.url | append: variant.url | json }}
}{% unless forloop.last %},{% endunless %}
{%- endfor -%}
]
}
</script>
Thank you for fixing it.
That's what I mean with "ST's JSON syntax is not optimized to work with templating engine".
It uses a lot of unnamed contexts, which can't be overridden by 3rd-party packages.
As of ST4134 JSON is highlighted within HTML Githubissues.
Hi, I have an issue with the code Script with
type="application/ld+json"
Not only does it have display problems, fold buttons also do not work, as the code cannot be hidden.
I'm not sure if this is a feature or a bug, can anyone confirm this for me?
I have created a discussion here, you can find more information about this issue
Sublime version: 4166 This issue does not appear on version 4107
Can you check it? Thank you.