Andreas Stenius 11 лет назад
Родитель
Сommit
490763fdb5
3 измененных файлов с 20 добавлено и 5 удалено
  1. 4 3
      src/erlydtl_beam_compiler.erl
  2. 1 1
      src/erlydtl_parser.yrl
  3. 15 1
      test/erlydtl_test_defs.erl

+ 4 - 3
src/erlydtl_beam_compiler.erl

@@ -766,9 +766,10 @@ blocktrans_ast(Args, Contents, PluralContents, TreeWalker) ->
                   {{LocalVarName, Ast}, {merge_info(AstInfoAcc, Info), TW}}
           end,
           {#ast_info{}, TreeWalker},
-          if is_tuple(Count) ->
-                  [Count|ArgList];
-             true ->
+          case Count of
+              {{identifier, _, Name}, Value} ->
+                  [{Name, Value}|ArgList];
+              _ ->
                   ArgList
           end),
 

+ 1 - 1
src/erlydtl_parser.yrl

@@ -401,7 +401,7 @@ EndBlockTransBraced -> open_tag endblocktrans_keyword close_tag.
 
 BlockTransArgs -> '$empty' : [].
 BlockTransArgs -> count_keyword Arg BlockTransArgs : [{count, '$2'}|'$3'].
-BlockTransArgs -> with_keyword Args BlockTransArgs : [{args, '$2'}|'$2'].
+BlockTransArgs -> with_keyword Args BlockTransArgs : [{args, '$2'}|'$3'].
 BlockTransArgs -> context_keyword string_literal BlockTransArgs : [{context, '$2'}|'$3'].
 
 BlockTransContents -> '$empty' : [].

+ 15 - 1
test/erlydtl_test_defs.erl

@@ -1366,7 +1366,21 @@ all_test_defs() ->
                       fun ({"There is just one foo..", {"There are many foo's..", 2}}, "baz") ->
                               "ok"
                       end}],
-        <<"ok">>}
+        <<"ok">>},
+       {"blocktrans a lot of stuff",
+        <<"{% blocktrans with foo=a.b count c=a|length context 'quux' %}"
+          "foo={{ foo }};bar={{ bar }};c={{ c }}:"
+          "{% plural %}"
+          "FOO:{{ foo }},BAR:{{ bar }},C:{{ c }}."
+          "{% endblocktrans %}">>,
+        [{a, [{b, "B"}]}, {bar, "BAR"}],
+        [{locale, "rub"},
+         {translation_fun, fun ({Single, {Plural, "1"=_Count}}, {Locale, Context}) ->
+                                   [Single, Plural, Locale, Context]
+                           end}],
+        <<"foo=B;bar=BAR;c=1:"
+          "FOO:B,BAR:BAR,C:1."
+          "rub" "quux">>}
       ]},
      {"verbatim",
       [{"Plain verbatim",