I would strongly suggest explaining the major difference between using URL and url in the following code:
Template.postItem.helpers({
domain: function() {
var a = document.createElement('a');
a.href = this.url; //lowercase matters!
return a.hostname;
}
});
For those of us using code completion tools and not cut/pasting directly from the book, it's pretty easy to make that mistake.
With URL, your script will grab the browser's current URL, which if you're developing locally will be localhost; url will correctly grab the value from the postsData array and display the hostname part of the url (aka the domain name).
More of a suggestion that an actual problem.
I would strongly suggest explaining the major difference between using
URL
andurl
in the following code:For those of us using code completion tools and not cut/pasting directly from the book, it's pretty easy to make that mistake.
With
URL
, your script will grab the browser's current URL, which if you're developing locally will belocalhost
;url
will correctly grab the value from thepostsData
array and display the hostname part of theurl
(aka the domain name).