@@ -107,20 +107,30 @@ defmodule Scrivener.HTML do
107107 view_style:
108108 opts [ :view_style ] || Application . get_env ( :scrivener_html , :view_style , :bootstrap )
109109 )
110+ |> Keyword . merge (
111+ hide_single:
112+ opts [ :hide_single ] || Application . get_env ( :scrivener_html , :hide_single , false )
113+ )
110114
111115 merged_opts = Keyword . merge ( @ defaults , opts )
112116
113117 path = opts [ :path ] || find_path_fn ( conn && paginator . entries , args )
114- params = Keyword . drop ( opts , Keyword . keys ( @ defaults ) ++ [ :path ] )
115-
116- # Ensure ordering so pattern matching is reliable
117- _pagination_links ( paginator ,
118- view_style: merged_opts [ :view_style ] ,
119- path: path ,
120- args: [ conn , merged_opts [ :action ] ] ++ args ,
121- page_param: merged_opts [ :page_param ] ,
122- params: params
123- )
118+ params = Keyword . drop ( opts , Keyword . keys ( @ defaults ) ++ [ :path , :hide_single ] )
119+
120+ hide_single_result = opts [ :hide_single ] && paginator . total_pages < 2
121+
122+ unless hide_single_result do
123+ # Ensure ordering so pattern matching is reliable
124+ _pagination_links ( paginator ,
125+ view_style: merged_opts [ :view_style ] ,
126+ path: path ,
127+ args: [ conn , merged_opts [ :action ] ] ++ args ,
128+ page_param: merged_opts [ :page_param ] ,
129+ params: params
130+ )
131+ else
132+ Phoenix.HTML . raw ( nil )
133+ end
124134 end
125135
126136 def pagination_links ( % Scrivener.Page { } = paginator ) ,
0 commit comments