@@ -21,6 +21,7 @@ if Code.ensure_loaded?(Igniter) do
2121 opts = [
2222 interactive?: true ,
2323 resource_plural: resource_plural ,
24+ resource_plural_for_routes: options [ :resource_plural_for_routes ] ,
2425 phx_version: options [ :phx_version ]
2526 ]
2627
@@ -105,18 +106,19 @@ if Code.ensure_loaded?(Igniter) do
105106
106107 defp live_route_instructions ( assigns , phx_version ) do
107108 module = if String . starts_with? ( phx_version , "1.8" ) , do: "Form" , else: "Index"
109+ prefix = assigns [ :route_prefix ]
108110
109111 [
110- ~s| live "/ #{ assigns [ :resource_plural ] } ", #{ assigns [ :resource_alias ] } Live.Index, :index\n | ,
112+ ~s| live "#{ prefix } ", #{ assigns [ :resource_alias ] } Live.Index, :index\n | ,
111113 if assigns [ :create_action ] do
112- ~s| live "/ #{ assigns [ :resource_plural ] } /new", #{ assigns [ :resource_alias ] } Live.#{ module } , :new\n |
114+ ~s| live "#{ prefix } /new", #{ assigns [ :resource_alias ] } Live.#{ module } , :new\n |
113115 end ,
114116 if assigns [ :update_action ] do
115- ~s| live "/ #{ assigns [ :resource_plural ] } /:id/edit", #{ assigns [ :resource_alias ] } Live.#{ module } , :edit\n \n |
117+ ~s| live "#{ prefix } /:id/edit", #{ assigns [ :resource_alias ] } Live.#{ module } , :edit\n \n |
116118 end ,
117- ~s| live "/ #{ assigns [ :resource_plural ] } /:id", #{ assigns [ :resource_alias ] } Live.Show, :show\n | ,
119+ ~s| live "#{ prefix } /:id", #{ assigns [ :resource_alias ] } Live.Show, :show\n | ,
118120 if assigns [ :update_action ] do
119- ~s| live "/ #{ assigns [ :resource_plural ] } /:id/show/edit", #{ assigns [ :resource_alias ] } Live.Show, :edit|
121+ ~s| live "#{ prefix } /:id/show/edit", #{ assigns [ :resource_alias ] } Live.Show, :edit|
120122 end
121123 ]
122124 |> Enum . reject ( & is_nil / 1 )
@@ -180,6 +182,8 @@ if Code.ensure_loaded?(Igniter) do
180182 create_action = action ( resource , opts , :create )
181183 update_action = action ( resource , opts , :update )
182184
185+ route_prefix = "/#{ opts [ :resource_plural_for_routes ] || plural_name } "
186+
183187 Keyword . merge ( assigns ,
184188 resource_singular: short_name ,
185189 resource_alias: Macro . camelize ( short_name ) ,
@@ -194,7 +198,7 @@ if Code.ensure_loaded?(Igniter) do
194198 pkey: pkey ,
195199 get_by_pkey: get_by_pkey ,
196200 attrs: attrs ( resource ) ,
197- route_prefix: "/ #{ plural_name } "
201+ route_prefix: route_prefix
198202 )
199203 end
200204
0 commit comments