Like for example: comparing variables, limiting the length of a text, comparing dates or even setting a temp variable for the loop.
One of the fundamental concept of mustache is this is a logic-less template engine, like many js template engine. So no if, not temp variable, nothing like that, just echoing values. I think you can call js helpers in templates but thats all.
I don't know how to structure the code so I share those helpers and templates for both PHP and JS.
Until now sharing template code between php and js is very cumbersome to do. It adds more problems than solutions. For your search example above, a common pattern is to always render the content with js templates.
There is many way of doing it. For instance you can put json in the blade view when you request the url with the browser, this json gets instantly rendered with js. Then when you update the query, you send an ajax request to the same url to update the json and re-render the result list. Other approach is to send an ajax request even the first time, which mean your page gets rendered with blank results then gets updated as soon as the ajax request finished.