@@ -709,15 +709,29 @@ defmodule Gettext.Macros do
709
709
"""
710
710
end
711
711
712
- # We support nil too in order to fall back to a nil context and always use the *p
713
- # variants of the Gettext macros.
712
+ validated_expand_to_binary ( term , env , raiser )
713
+ end
714
+
715
+ defp validated_expand_to_binary ( { :<> , _ , pieces } , env , raiser ) do
716
+ Enum . map_join ( pieces , & validated_expand_to_binary ( & 1 , env , raiser ) )
717
+ end
718
+
719
+ defp validated_expand_to_binary ( { :<<>> , _ , pieces } , env , raiser ) do
720
+ Enum . map_join ( pieces , & validated_expand_to_binary ( & 1 , env , raiser ) )
721
+ end
722
+
723
+ # We support nil too in order to fall back to a nil context and always use the *p
724
+ # variants of the Gettext macros.
725
+ defp validated_expand_to_binary ( term , _env , _raiser )
726
+ when is_binary ( term ) or is_nil ( term ) do
727
+ term
728
+ end
729
+
730
+ defp validated_expand_to_binary ( term , env , raiser ) do
714
731
case Macro . expand ( term , env ) do
715
732
term when is_binary ( term ) or is_nil ( term ) ->
716
733
term
717
734
718
- { :<<>> , _ , pieces } = term ->
719
- if Enum . all? ( pieces , & is_binary / 1 ) , do: Enum . join ( pieces ) , else: raiser . ( term )
720
-
721
735
other ->
722
736
raiser . ( other )
723
737
end
0 commit comments