Permalink
Browse files

Setup a `domain` helper on the `postItem`.

chapter3-2
  • Loading branch information...
tmeasday committed Apr 7, 2013
1 parent 9ceb5f8 commit 0852258aa39d098b19b0ec71c27a53d398e3ea02
Showing with 7 additions and 0 deletions.
  1. +7 −0 client/templates/posts/post_item.js
@@ -0,0 +1,7 @@
Template.postItem.helpers({
domain: function() {
var a = document.createElement('a');
a.href = this.url;
return a.hostname;
}
});

4 comments on commit 0852258

@lovetokill69

This comment has been minimized.

Show comment
Hide comment
@lovetokill69

lovetokill69 Jan 13, 2016

เอาไวทำไร

เอาไวทำไร

@Morlin1

This comment has been minimized.

Show comment
Hide comment
@Morlin1

Morlin1 Jun 29, 2016

It's not a good solution to name it as helpers

It's not a good solution to name it as helpers

@Grafissto

This comment has been minimized.

Show comment
Hide comment
@Grafissto

Grafissto Mar 22, 2017

Esta bien, es exactamente igual al ejercicio.

Esta bien, es exactamente igual al ejercicio.

@yvgorshkov

This comment has been minimized.

Show comment
Hide comment
@yvgorshkov

yvgorshkov Mar 25, 2017

Template.postItem.helpers({
  domain: function() {
    var a = document.createElement('a');
console.log(a);
    a.href = this.url;
console.log(a);
    return a.hostname;
  }
});

Why do both calls console.log(a) give the same result? After all, in the first case there must be just a skeleton of an element a.

Template.postItem.helpers({
  domain: function() {
    var a = document.createElement('a');
console.log(a);
    a.href = this.url;
console.log(a);
    return a.hostname;
  }
});

Why do both calls console.log(a) give the same result? After all, in the first case there must be just a skeleton of an element a.

Please sign in to comment.