4 ms·
This makes sense to me. Views always seemed a like unnecessary boilerplate to me. Better to keep all the code together in one module, and just import common fu
by gnutrino 4y ago
This makes sense to me. Views always seemed a like unnecessary boilerplate to me. Better to keep all the code together in one module, and just import common functions. On the other hand, I don't typically like defining the template in a sigil, unless it's a really small one, so I probably won't do that much.
- freedomben 4y agoI agree in the case of HTML rendering, but I write a lot of JSON APIs and putting the JSON definition in the View has been very pleasant. It didn't say in OP, but how does this change an API? Maybe a `GreetJSON` instead of `GreetHTML`?
- a_bored_husky 4y agoYes, exactly like that.
- eclark 4y agoCorrect. You write a moduleJSON. So this is about what we have for one of our controller/views: defmodule MyWeb.SystemStateJSON do def index(%{summary: summary}) do %{data: summary} end end