kirbysayshi / vash

Vash, the 60 billion double-dollar template-maker. Razor syntax, for JavaScript templates
Other
524 stars 60 forks source link

Render crash when using JSON-LD script #113

Closed CptMaumau closed 7 years ago

CptMaumau commented 7 years ago

When using a JSON-LD script in a view, it crashes.

Any idea of to fix it or is it a bug?

Here is an example of a JSON-LD script.

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Product",
  "aggregateRating": {
    "@type": "AggregateRating",
    "ratingValue": "3.5",
    "reviewCount": "11"
  },
  "description": "0.7 cubic feet countertop microwave. Has six preset cooking categories and convenience features like Add-A-Minute and Child Lock.",
  "name": "Kenmore White 17\" Microwave",
  "image": "kenmore-microwave-17in.jpg",
  "offers": {
    "@type": "Offer",
    "availability": "http://schema.org/InStock",
    "price": "55.00",
    "priceCurrency": "USD"
  },
}
</script>
yannik-b commented 7 years ago

It's easy. Vash used the @ Syntax to identify a variable. So your json ld takes vash to think @context should be a variable, but it isn't. Try adding a backslash before every @ to tell vash it is a string.

CptMaumau commented 7 years ago

Thank you that was it! The way to fix is to put another @ before, I had a similar issue recently but forgot about that.