Reputation: 10512
I'm passing an object to mustache and this object has a method with one parameter. Is something like this possible with Mustache and PHP?
{{object.method(parameter)}}
If it gets too laborious to achieve this with Mustache, what template engine would you recommend?
Remember I need to pass parameters to object methods while in the view context (like we do with helpers). The nearest as possible to mustache syntax is welcome.
Upvotes: 0
Views: 1389
Reputation: 5117
This is not possible in Mustache.
That said, you could probably solve whatever it is that you're looking to solve with a proper ViewModel, which is a more Mustache approach.
If you absolutely must be able to pass parameters to object methods, we're talking about logic in your templates. While not an inherently bad thing, this is definitely not a Mustache thing :)
For a solid templating language for PHP (besides Mustache, of course), I'd recommend Twig.
Upvotes: 4