Stringify?
See original GitHub issueAs far as I can see in liquid.js
and render.js
, the logic is:
function stringify(val) {
if (typeof val === 'string') return val;
return JSON.stringify(val);
}
This is generally ok, except for objects which have a toString()
function.
As far as I understood from the MDN site, the safe test for string would be:
Object.prototype.toString.call(x) === '[object String]'
Until a fix will be available, a possible workaround is to add a getter:
get toStr () {
return this.toString()
}
and in the template use it explicitly {{ object.toStr }}
.
There is also a problem with JSON.stringify()
, for complex objects it fails with Converting circular structure to JSON
.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() method converts a JavaScript value to a JSON string, optionally replacing values if a replacer function is specified or ...
Read more >JSON.stringify() - W3Schools
JSON.stringify() ... A common use of JSON is to exchange data to/from a web server. When sending data to a web server, the...
Read more >JavaScript JSON stringify() Method - GeeksforGeeks
The JSON.stringify() method in Javascript is used to create a JSON string out of it. While developing an application using JavaScript, ...
Read more >JSON Stringify Online
JSON Stringify Online helps convert string value to JSON String using JSON.Stringify(). It's very simple and easy way to create JSON String value...
Read more >stringify - Wiktionary
To find the first digit in a positive number, stringify it and take the first character.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Both
to_liquid
andtoLiquid
supported, published @5.2.0Thank you!