samedi 10 janvier 2015

Ember / Handlebars giving [object Object] instead of string from JSON object

Overview


Hello, I am learning Ember.js and I am connecting to a Wordpress site I control via the Wordpress JSON API plugin.


Using the JSON API from the plugin I'm able to easily pull in the WordPress post title, author name, publish date, post excerpt, etc for any post without problems. However, when I try and use the post content, I get [object Object] back instead of the expected string.


Looking directly at the JSON object I'm working with, both excerpt and content are items in the JSON object which are each equal to a string of HTML. The only difference between the two appears to be the length of the string. using {{{excerpt}}} returns the string and allows the HTML to be properly formatted while {{{content}}} just prints out '[object Object]'.


The Handlebars Template



<script type="text/x-handlebars" id="post">
<div class="post">
<h1>{{title}}</h1>
<h2>by {{author.name}} <small class="muted">({{date}})</small></h2>

<hr>

<div class="below-the-fold">
{{{content}}}
</div>
</div>


The Rendered HTML by Ember



<div class="post">
<h1>Sample Post</h1>
<h2>by Boydbme <small class="muted">(2015-01-10 11:32:36)</small></h2>

<hr>

<div class="below-the-fold">
[object Object]
</div>
</div>


the JSON object I'm working with



post: {
id: 1306,
type: "post",
slug: "sample-post",
url: "#removed_for_stack_overflow",
status: "publish",
title: "Sample Post",
title_plain: "Sample Post",
content: "<p class="p1"><span class="s1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur iusto, illum minus suscipit magni provident sit vitae modi quasi nulla, totam nobis, quaerat soluta repellat alias reprehenderit beatae, pariatur. Nobis eaque sit nihil reprehenderit, sapiente aliquam maxime excepturi unde nemo odio nesciunt nulla maiores ad, perferendis est sunt harum fuga.</span></p> <p class="p1"><span class="s1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur iusto, illum minus suscipit magni provident sit vitae modi quasi nulla, totam nobis, quaerat soluta repellat alias reprehenderit beatae, pariatur. Nobis eaque sit nihil reprehenderit, sapiente aliquam maxime excepturi unde nemo odio nesciunt nulla maiores ad, perferendis est sunt harum fuga.</span></p> <p class="p1"><span class="s1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur iusto, illum minus suscipit magni provident sit vitae modi quasi nulla, totam nobis, quaerat soluta repellat alias reprehenderit beatae, pariatur. Nobis eaque sit nihil reprehenderit, sapiente aliquam maxime excepturi unde nemo odio nesciunt nulla maiores ad, perferendis est sunt harum fuga.</span></p> <p class="p1"><span class="s1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur iusto, illum minus suscipit magni provident sit vitae modi quasi nulla, totam nobis, quaerat soluta repellat alias reprehenderit beatae, pariatur. Nobis eaque sit nihil reprehenderit, sapiente aliquam maxime excepturi unde nemo odio nesciunt nulla maiores ad, perferendis est sunt harum fuga.</span></p> <p class="p1"><span class="s1">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur iusto, illum minus suscipit magni provident sit vitae modi quasi nulla, totam nobis, quaerat soluta repellat alias reprehenderit beatae, pariatur. Nobis eaque sit nihil reprehenderit, sapiente aliquam maxime excepturi unde nemo odio nesciunt nulla maiores ad, perferendis est sunt harum fuga.</span></p>",
excerpt: "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequatur iusto, illum minus suscipit magni provident sit vitae modi quasi nulla, totam nobis, quaerat soluta repellat alias reprehenderit beatae, pariatur. Nobis eaque sit nihil reprehenderit, sapiente aliquam maxime excepturi unde nemo odio nesciunt nulla maiores ad, perferendis est sunt harum fuga.<a class="read-more" href="#removed_for_stack_overflow">Read More &raquo;</a></p> ",
date: "2015-01-10 11:32:36",
modified: "2015-01-10 11:32:36",
categories: [],
tags: [],
author: {},
comments: [],
attachments: [],
comment_count: 0,
comment_status: "closed",
thumbnail: "#removed_for_stack_overflow",
custom_fields: {},
thumbnail_size: "post-thumbnail",
thumbnail_images: {}
},


Any help would be greatly appreciated. My confusion comes from being able to use {{{excerpt}}} and get a string in my template as expected, but being unable to do the same with {{{content}}}.


Thanks!


Aucun commentaire:

Enregistrer un commentaire