11defmodule ElixirBoilerplateWeb do
2- @ moduledoc """
3- The entrypoint for defining your web interface, such
4- as controllers, components, channels, and so on.
5- This can be used in your application as:
6- use ElixirBoilerplateWeb, :controller
7- use ElixirBoilerplateWeb, :html
8- The definitions below will be executed for every controller,
9- component, etc, so keep them short and clean, focused
10- on imports, uses and aliases.
11- Do NOT define functions inside the quoted expressions
12- below. Instead, define additional modules and import
13- those modules here.
14- """
15-
162 def static_paths , do: ~w( assets fonts images favicon.ico robots.txt)
173
18- def router do
19- quote do
20- use Phoenix.Router , helpers: false
21-
22- # Import common connection and controller functions to use in pipelines
23- import Plug.Conn
24- import Phoenix.Controller
25- import Phoenix.LiveView.Router
26- end
27- end
28-
29- def channel do
30- quote do
31- use Phoenix.Channel
32- end
33- end
34-
35- def controller do
36- quote do
37- use Phoenix.Controller ,
38- namespace: ElixirBoilerplateWeb ,
39- formats: [ :html , :json ] ,
40- layouts: [ html: ElixirBoilerplateWeb.Layouts ]
41-
42- import Plug.Conn
43- import ElixirBoilerplate.Gettext
44-
45- unquote ( verified_routes ( ) )
46- end
47- end
48-
49- def live_view do
50- quote do
51- use Phoenix.LiveView ,
52- layout: { ElixirBoilerplateWeb.Layouts , :live }
53-
54- unquote ( html_helpers ( ) )
55- end
56- end
57-
58- def live_component do
59- quote do
60- use Phoenix.LiveComponent
61-
62- unquote ( html_helpers ( ) )
63- end
64- end
65-
66- def html do
67- quote do
68- use Phoenix.Component
69-
70- # Import convenience functions from controllers
71- import Phoenix.Controller ,
72- only: [ get_csrf_token: 0 , view_module: 1 , view_template: 1 ]
73-
74- # Include general helpers for rendering HTML
75- unquote ( html_helpers ( ) )
76- end
77- end
78-
79- defp html_helpers do
4+ def html_helpers do
805 quote do
816 # HTML escaping functionality
827 import Phoenix.HTML
8+
839 # Core UI components and translation
8410 import ElixirBoilerplate.Gettext
85- import ElixirBoilerplateWeb.Components.Branding
8611 import ElixirBoilerplateWeb.Components.Core
8712
8813 # Shortcut for generating JS commands
@@ -101,11 +26,4 @@ defmodule ElixirBoilerplateWeb do
10126 statics: ElixirBoilerplateWeb . static_paths ( )
10227 end
10328 end
104-
105- @ doc """
106- When used, dispatch to the appropriate controller/view/etc.
107- """
108- defmacro __using__ ( which ) when is_atom ( which ) do
109- apply ( __MODULE__ , which , [ ] )
110- end
11129end
0 commit comments