jeudi 9 avril 2015

I need some ideas for this. Emberjs

I have a helper named format-log



//format-log.js
import Ember from 'ember';

export function formatLog(text) {
var hashtag = text.match(/[#]\w+/g);
var newText = text;
if (hashtag !== null && hashtag !== undefined) {
for ( var i = 0; i < hashtag.length; i++){
newText = newText.replace(hashtag[i], "<a href='' class='hash'>"+ hashtag[i] +"</a>");
}
return newText;
}else{
return text;
}

}

export default Ember.Handlebars.makeBoundHelper(formatLog);


When I make a new log, I have the need to add a hashtag for example


"This is a example #log"


That text go-through the helper and returns this format


"This is a example < a href="">#log< /a>"


I wanna filter all log that contains the same hashtag make something like Trends Twitter, I am using Ember cli and ember-data


My model



//log.js
import DS from 'ember-data';

export default DS.Model.extend({
text: DS.attr('string'),
date: DS.attr('date')
});




Aucun commentaire:

Enregistrer un commentaire