我有两个文件,其中包括:
def do_query_sys_status do
f = EEx.eval_file("templates/do_query_sys_status.eex",
[assigns: [data: %{sysvar: 3, coutry_id: 1, webapi_key: "abc123456" }]])
IO.puts f
end和一个模板文件:
<x:Envelope xmlns:x="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ser="https://webapi.allegro.pl/service.php">
<x:Header/>
<x:Body>
<ser:DoQuerySysStatusRequest>
<ser:sysvar><%= @data.sysvar =></ser:sysvar>
<ser:countryId><%= @data.country_id %></ser:countryId>
<ser:webapiKey><%= @data.webapi_key %></ser:webapiKey>
</ser:DoQuerySysStatusRequest>
</x:Body>
</x:Envelope>运行它之后,我得到了一个错误:
** (SyntaxError) templates/do_query_sys_status.eex:7: keyword argument must be followed by space after: ser:
lib/eex/compiler.ex:34: EEx.Compiler.generate_buffer/4
lib/eex.ex:209: EEx.eval_file/3
(bankinfo_api) lib/bankinfo_api.ex:25: BankinfoApi.do_query_sys_status/0
(stdlib) erl_eval.erl:669: :erl_eval.do_apply/6
(iex) lib/iex/evaluator.ex:117: IEx.Evaluator.handle_eval/5是否有必要以某种方式逃避模板?我还没找到什么办法。
发布于 2015-12-25 13:22:44
你的代码里有排字
coutry_id应该是
country_idtemplates/do_query_sys_status.eex的第6行应该是
<ser:sysvar><%= @data.sysvar %></ser:sysvar>https://stackoverflow.com/questions/34462589
复制相似问题