@@ -709,15 +709,29 @@ defmodule Gettext.Macros do
709709 """
710710 end
711711
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
714731 case Macro . expand ( term , env ) do
715732 term when is_binary ( term ) or is_nil ( term ) ->
716733 term
717734
718- { :<<>> , _ , pieces } = term ->
719- if Enum . all? ( pieces , & is_binary / 1 ) , do: Enum . join ( pieces ) , else: raiser . ( term )
720-
721735 other ->
722736 raiser . ( other )
723737 end
0 commit comments