defmodule MyApp.ShowUser do
use Raxx.Server
use Raxx.View,
arguments: [:user],
template: "show_user.html.eex",
layout "../layout.html.eex"
@impl Raxx.Server
def handle_request(_request, _state) do
user = %{name: "Alice"}
response(:ok)
|> render(user)
end
end
It can also be used in a separate view just as easily
defmodule MyApp.ShowUserView do
use Raxx.View,
arguments: [:user],
template: "show_user.html.eex",
layout "../layout.html.eex"
end
# Then in use it anywere by calling
response(:ok)
|> MyApp.ShowUserView.render(user)
Add a view layer that can be used as follows.
It can also be used in a separate view just as easily
TODO include an EEx.Engine that handles html escaping. https://www.owasp.org/index.php/XSS_(Cross_Site_Scripting)_Prevention_Cheat_Sheet#RULE_.232_-_Attribute_Escape_Before_Inserting_Untrusted_Data_into_HTML_Common_Attributes