gwendall/way.js

Filter function

Closed this issue · 9 comments

In AngularJs, it has a functionality that allow you to specify the format function for data.
https://docs.angularjs.org/api/ng/filter

For instance,

{{myData | uppercase}}

If myData='aabbcc', the content will be displayed as 'AABBCC'.

Is it possible to add such similar feature?

I could see some kind of transformation layer being helpful. It seems like the idea here is to be as javascript-less as possible though. Making it an option, though, could be nice.

Why not just have a way-filter DOM tag? Surely that would be javascript-less?

+1, will investigate that. Again, PR are welcome!

On 21 August 2014 22:04, Micheal Harker notifications@github.com wrote:

Why not just have a way-filter DOM tag? Surely that would be
javascript-less?


Reply to this email directly or view it on GitHub
#21 (comment).

I have just submitted a pull request, @gwendall - hope to see it merged :)

I am fine with the 'way-filter' DOM tag. However, the actual 'format' function should be externalized, and let the developer define.

Suppose I have my own format function.

function prependUnderscore(str) {
  if (!str) return '';
  return '_' + str;
}

Then it would look like

way-filter='prependUnderscore'

I have added the possibility of custom filters to my pull request. My implementation is as such:

function filtername(str) {
     return "string to return";
}

Right on. Pushed what seems to be a correct implementation. Check it out. https://github.com/gwendall/way.js#filters

Pull requests welcome for more cool pre-built filters!

https://github.com/gwendall/way.js/blob/master/way.js#L224

Btw, will rename it to "way-transform" tomm to keep the "way-filter" as an attribute to filter repeats.

Sent from my iPhone

On 21 août 2014, at 23:21, Amec Niv notifications@github.com wrote:

Closed #21.


Reply to this email directly or view it on GitHub.