Filter function Filter vuejs

filters:{
    str_limit : function (text,limit) {
      if(!text){
        return '';
      }
     else if(text.length()<limit){
        return text;
      }
      else {
        return text.substring(0,limit);
      }
    }
  }
// register the previous filter in your componenet as a local filter
// then in your html
{{ valueToDisplay | str_limit(256) }} // we set the limit of that text to 256 char
saad hassouane