Skip to content

Commit 53946c8

Browse files
zolrathmhanberg
andauthored
feat: projections for phoenix 1.7 (#50)
Co-authored-by: Mitchell Hanberg <mitch@mitchellhanberg.com>
1 parent 86bda38 commit 53946c8

File tree

1 file changed

+67
-5
lines changed

1 file changed

+67
-5
lines changed

lua/elixir/projectionist/init.lua

Lines changed: 67 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ local config = {
1212
},
1313
},
1414
["test/**/views/*_view_test.exs"] = {
15-
alternate = "lib/{dirname}/views/{basename}_view.ex",
1615
type = "test",
16+
alternate = "lib/{dirname}/views/{basename}_view.ex",
1717
template = {
1818
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}ViewTest do",
1919
" use ExUnit.Case, async: true",
@@ -32,14 +32,76 @@ local config = {
3232
},
3333
},
3434
["test/**/controllers/*_controller_test.exs"] = {
35-
alternate = "lib/{dirname}/controllers/{basename}_controller.ex",
3635
type = "test",
36+
alternate = "lib/{dirname}/controllers/{basename}_controller.ex",
3737
template = {
3838
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}ControllerTest do",
3939
" use {dirname|camelcase|capitalize}.ConnCase, async: true",
4040
"end",
4141
},
4242
},
43+
["lib/**/controllers/*_html.ex"] = {
44+
type = "html",
45+
alternate = "test/{dirname}/controllers/{basename}_html_test.exs",
46+
template = {
47+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}HTML do",
48+
" use {dirname|camelcase|capitalize}, :html",
49+
"",
50+
[[ embed_templates "{basename|snakecase}_html/*"]],
51+
"end",
52+
},
53+
},
54+
["test/**/controllers/*_html_test.exs"] = {
55+
type = "test",
56+
alternate = "lib/{dirname}/controllers/{basename}_html.ex",
57+
template = {
58+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}HTMLTest do",
59+
" use {dirname|camelcase|capitalize}.ConnCase, async: true",
60+
"",
61+
" alias {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}HTML",
62+
"end",
63+
},
64+
},
65+
["lib/**/components/*.ex"] = {
66+
type = "component",
67+
alternate = "test/{dirname}/components/{basename}_test.exs",
68+
template = {
69+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize} do",
70+
" use Phoenix.Component",
71+
"end",
72+
},
73+
},
74+
["test/**/components/*_test.exs"] = {
75+
type = "test",
76+
alternate = "lib/{dirname}/components/{basename}.ex",
77+
template = {
78+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}Test do",
79+
" use {dirname|camelcase|capitalize}.ConnCase, async: true",
80+
"",
81+
" alias {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}",
82+
"end",
83+
},
84+
},
85+
["lib/**/live/*_live.ex"] = {
86+
type = "liveview",
87+
alternate = "test/{dirname}/live/{basename}_live_test.exs",
88+
template = {
89+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}Live do",
90+
" use {dirname|camelcase|capitalize}, :live_view",
91+
"end",
92+
},
93+
},
94+
["test/**/live/*_live_test.exs"] = {
95+
type = "test",
96+
alternate = "lib/{dirname}/live/{basename}_live.ex",
97+
template = {
98+
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}LiveTest do",
99+
" use {dirname|camelcase|capitalize}.ConnCase",
100+
"",
101+
" import Phoenix.LiveViewTest",
102+
"end",
103+
},
104+
},
43105
["lib/**/channels/*_channel.ex"] = {
44106
type = "channel",
45107
alternate = "test/{dirname}/channels/{basename}_channel_test.exs",
@@ -50,8 +112,8 @@ local config = {
50112
},
51113
},
52114
["test/**/channels/*_channel_test.exs"] = {
53-
alternate = "lib/{dirname}/channels/{basename}_channel.ex",
54115
type = "test",
116+
alternate = "lib/{dirname}/channels/{basename}_channel.ex",
55117
template = {
56118
"defmodule {dirname|camelcase|capitalize}.{basename|camelcase|capitalize}ChannelTest do",
57119
" use {dirname|camelcase|capitalize}.ChannelCase, async: true",
@@ -69,13 +131,13 @@ local config = {
69131
},
70132
},
71133
["lib/*.ex"] = {
72-
alternate = "test/{}_test.exs",
73134
type = "source",
135+
alternate = "test/{}_test.exs",
74136
template = { "defmodule {camelcase|capitalize|dot} do", "end" },
75137
},
76138
["test/*_test.exs"] = {
77-
alternate = "lib/{}.ex",
78139
type = "test",
140+
alternate = "lib/{}.ex",
79141
template = {
80142
"defmodule {camelcase|capitalize|dot}Test do",
81143
" use ExUnit.Case, async: true",

0 commit comments

Comments
 (0)