π§Util & Helpers
We have two files to put helper functions:
Util
(/lib/petal_pro/util/util.ex
) - utility functions used anywhere, eg.random_string()
PetalProWeb.Helpers
(lib/petal_pro_web/helpers.ex
)- utilities functions imported into views (templates and live views), eg.main_menu_items()
,is_admin?
If you want to add new helpers, ask "is this only going to be used in templates and live views?". If yes then put it in helpers.ex
. If "no", put it in util.ex
.
Last updated