{"action":"created","issue":{"url":"https://api.github.com/repos/erlydtl/erlydtl/issues/216","labels_url":"https://api.github.com/repos/erlydtl/erlydtl/issues/216/labels{/name}","comments_url":"https://api.github.com/repos/erlydtl/erlydtl/issues/216/comments","events_url":"https://api.github.com/repos/erlydtl/erlydtl/issues/216/events","html_url":"https://github.com/erlydtl/erlydtl/pull/216","id":104012453,"number":216,"title":"Be precise about gb_trees struct to avoid problems with simple tuples","user":{"login":"oxpa","id":1932978,"avatar_url":"https://avatars.githubusercontent.com/u/1932978?v=3","gravatar_id":"","url":"https://api.github.com/users/oxpa","html_url":"https://github.com/oxpa","followers_url":"https://api.github.com/users/oxpa/followers","following_url":"https://api.github.com/users/oxpa/following{/other_user}","gists_url":"https://api.github.com/users/oxpa/gists{/gist_id}","starred_url":"https://api.github.com/users/oxpa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oxpa/subscriptions","organizations_url":"https://api.github.com/users/oxpa/orgs","repos_url":"https://api.github.com/users/oxpa/repos","events_url":"https://api.github.com/users/oxpa/events{/privacy}","received_events_url":"https://api.github.com/users/oxpa/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-08-31T08:50:00Z","updated_at":"2015-08-31T10:42:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/erlydtl/erlydtl/pulls/216","html_url":"https://github.com/erlydtl/erlydtl/pull/216","diff_url":"https://github.com/erlydtl/erlydtl/pull/216.diff","patch_url":"https://github.com/erlydtl/erlydtl/pull/216.patch"},"body":"Hello.\r\n\r\nConsider I'd like to render a list of tuples like this one: {year, [{month, [day1,day2] }] }\r\n```\r\n1>{ok, T} = erlydtl:compile_template(\"{{dates}}, {% for y in dates %}{{y.1}} {% for m in y.2 %} {{m.1}} {% endfor %}{% endfor %}\", test1).\r\nCompile template: {{dates}}, {% for y in dates %}{...\r\n{ok,test1}\r\n2>T:render([{dates,[{2015,[{8,[27,30]}]}]}]).\r\n** exception error: no function clause matching gb_trees:lookup_1(1,[{8,[27,30]}]) (gb_trees.erl, line 201)\r\n     in function  erlydtl_runtime:find_value/2 (src/erlydtl_runtime.erl, line 76)\r\n     in call from erlydtl_runtime:fetch_value/4 (src/erlydtl_runtime.erl, line 142)\r\n     in call from test1:'-render_internal/2-fun-1-'/3 (, line 1173)\r\n     in call from lists:mapfoldl/3 (lists.erl, line 1352)\r\n     in call from erlydtl_runtime:forloop/4 (src/erlydtl_runtime.erl, line 399)\r\n     in call from test1:render_internal/2 (, line 1384)\r\n     in call from test1:render/2 (, line 495)\r\n```\r\nThe tuple is mistaken for a gb_tree. The patch describes gb_tree more accurate (a tuple of int and 4 element or 'nil'). \r\nThe result would be \r\n```\r\n1> {ok, T} = erlydtl:compile_template(\"{{dates}}, {% for y in dates %}{{y.1}} {% for m in y.2 %} {{m.1}} {% endfor %}{% endfor %}\", test1).\r\nCompile template: {{dates}}, {% for y in dates %}{...\r\ntest1: Warning: Compiled template not saved (need out_dir option)\r\n{ok,test1}\r\n 2> T:render([{dates,[{2015,[{8,[27,30]}]}]}]).\r\n{ok,[[<<\"{2015,[{8,[27,30]}]}\">>],\r\n     <<\", \">>,\r\n     [[\"2015\",<<\" \">>,[[<<\" \">>,\"8\",<<\" \">>]]]]]}\r\n```\r\nI'm not really familiar with gb_trees, so please review the patch before merging.\r\n\r\nUPD: the post is updated by @seriyps notice: i posted the wrong stacktrace."},"comment":{"url":"https://api.github.com/repos/erlydtl/erlydtl/issues/comments/136330190","html_url":"https://github.com/erlydtl/erlydtl/pull/216#issuecomment-136330190","issue_url":"https://api.github.com/repos/erlydtl/erlydtl/issues/216","id":136330190,"user":{"login":"oxpa","id":1932978,"avatar_url":"https://avatars.githubusercontent.com/u/1932978?v=3","gravatar_id":"","url":"https://api.github.com/users/oxpa","html_url":"https://github.com/oxpa","followers_url":"https://api.github.com/users/oxpa/followers","following_url":"https://api.github.com/users/oxpa/following{/other_user}","gists_url":"https://api.github.com/users/oxpa/gists{/gist_id}","starred_url":"https://api.github.com/users/oxpa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oxpa/subscriptions","organizations_url":"https://api.github.com/users/oxpa/orgs","repos_url":"https://api.github.com/users/oxpa/repos","events_url":"https://api.github.com/users/oxpa/events{/privacy}","received_events_url":"https://api.github.com/users/oxpa/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T10:42:48Z","updated_at":"2015-08-31T10:42:48Z","body":"Gave it a thought: added a simple test which fails without a patch but works with it. "}}