gobuffalo / plush

The powerful template system that Go needs
MIT License
895 stars 57 forks source link

Load sprig functions #161

Closed pjebs closed 2 years ago

pjebs commented 2 years ago

There is the popular package called sprig: https://github.com/Masterminds/sprig. It contains lots of functions: http://masterminds.github.io/sprig/ that can be used for the standard template package.

How can I load those functions into plush so I can use them with plush?

sio4 commented 2 years ago

Actually, I have no experience with Sprig but I understood it as yet another template engine for Go. I don't think users can use functions from Sprig in Plush directly. Those functions live (available) in that templating engine while Plush's functions live (available) in Plush.

I feel like your question is similar to "how can I load methods of class A in class B". The answer could be "implementing those functions in Plush", but I don't think that is a valid feature request since it is too rough (ambiguous). If you find a specific nice function and it could be helpful for many plush users too, you can tell us which function/functionality is required for which purpose, and let us know how that will help users. We may be able to consider adding that function to Plush.

Another approach could be supporting Sprig with a new renderer of buffalo or with a custom rendering engine directly from your own app. Even though that can be considerable (however not in short term in buffalo), that is not in the scope of Plush.