Skip to content

Instantly share code, notes, and snippets.

@etozzato
Created July 30, 2014 17:37
Show Gist options
  • Save etozzato/af866d3c7b93a1342cad to your computer and use it in GitHub Desktop.
Save etozzato/af866d3c7b93a1342cad to your computer and use it in GitHub Desktop.
// My Annotation object has labels, but only carries the list of label values
// "labels":["terr","anno"]
// This is the form of the full annotationLabel
// {"id":1,"label":"Terrifying","value":"terr"}
// {"id":2,"label":"Annoying","value":"anno"}
// This is the ebmlemjs view
.m-response-labels
activeLabelsList annotation.labels
// And the problem is solved with an Helper that returns HTML.. not my favorite solution
// but it works okay for this case! \0/
Ember.Handlebars.registerBoundHelper('activeLabelsList', function(labels) {
var _labels;
_labels = (this.get('labels').filter(function(label) {
return labels.contains(label.get('value'));
})).map(function(el) {
return "<div class='m-label " + (el.get('className')) + "'>" + (el.get('label')) + "</div>";
});
return new Handlebars.SafeString(_labels.join(' '));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment