question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

2.0 rc-7 toString() expression not works inside mustache {{}}

See original GitHub issue

Hello ! I am very new Vue. Sorry if I miss something in documentation.

I have a very simple template witch is not working as expected. I do not know exactly context of this.toString() but it is not vm.$data.

<div id="app">
    {{ this.toString() }} <!--should return $data.toString() but not works -->
</div>

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fnlctrlcommented, Sep 25, 2016

@LinusBorg

the template has not this context.

It actually has… so it can access methods, $options etc. $data is on this, so the docs were correct. http://jsfiddle.net/r9kojstk/

Since this is an object (that didn’t override toString), using this.toString() simply gives [object Object], which is expected.

1reaction
LinusBorgcommented, Sep 25, 2016

the template has not this context.

It simply has access to all properties and methods of the vm as variables. $data is one of those properties.

<div id="app">
    {{ $data.toString() }} // also works without .toString()
</div>

to get a nice format, simply use a <pre> element:

<div id="app">
    <pre>{{ $data }}</pre>
</div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Mustache.java should not fail when tostring of an object ...
test case: public static class ObjectWithPropertyWithNullToString { public Object property = new Object() { @Override public String ...
Read more >
How to ignore a handlebars expression in Mustache templates?
Needless to say there is no actual way to escape them. The trick is to just emit a string value of handlebars. Share....
Read more >
WhatsNew 2.0 | Ktor Framework
i upload my ktor project to heroku server and succeffly upload and it work only for simple request put when it go inside...
Read more >
Logic-less templates. - mustache(5)
It works by expanding tags in a template using values provided in a hash or object. We call it "logic-less" because there are...
Read more >
Introduction to Mustache - Baeldung
Mustache is a logicless template engine for creating dynamic content like HTML, configuration files among other things. 2. Introduction.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found