Created
October 22, 2016 19:30
-
-
Save bnhansn/4112c42b25f90a9fac7e8f3854002fc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Sling.MessageView do | |
use Sling.Web, :view | |
def render("index.json", %{messages: messages, pagination: pagination}) do | |
%{ | |
data: render_many(messages, Sling.MessageView, "message.json"), | |
pagination: pagination | |
} | |
end | |
def render("message.json", %{message: message}) do | |
%{ | |
id: message.id, | |
inserted_at: message.inserted_at, | |
text: message.text, | |
user: %{ | |
email: message.user.email, | |
username: message.user.username | |
} | |
} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment