knockout.punches icon indicating copy to clipboard operation
knockout.punches copied to clipboard

Possibility to access enclosing element in text filter?

Open SimmeNilsson opened this issue 4 years ago • 2 comments

Basically I want the same behavior of the "| default: " filter but I have the need to make the text italics when it should display "Missing". Still want HTML escape and so on though. Would it be possible to access the enclosing element to attach a class or a style to it?

SimmeNilsson avatar Mar 03 '20 17:03 SimmeNilsson

Perhaps it could be built in, but you can always pass the element to the filter: text: field | filter:$element

mbest avatar Mar 13 '20 07:03 mbest

Thank you! I was not aware of that opportunity. It works, but not having to pass it in for every use would have been nice... :) text: field | missing

SimmeNilsson avatar Mar 16 '20 13:03 SimmeNilsson