{"action":"created","issue":{"url":"https://api.github.com/repos/spf13/hugo/issues/2514","repository_url":"https://api.github.com/repos/spf13/hugo","labels_url":"https://api.github.com/repos/spf13/hugo/issues/2514/labels{/name}","comments_url":"https://api.github.com/repos/spf13/hugo/issues/2514/comments","events_url":"https://api.github.com/repos/spf13/hugo/issues/2514/events","html_url":"https://github.com/spf13/hugo/issues/2514","id":180486377,"number":2514,"title":"html/template:  on range loop re-entry: ambiguous URL context","user":{"login":"alrayyes","id":511318,"avatar_url":"https://avatars.githubusercontent.com/u/511318?v=3","gravatar_id":"","url":"https://api.github.com/users/alrayyes","html_url":"https://github.com/alrayyes","followers_url":"https://api.github.com/users/alrayyes/followers","following_url":"https://api.github.com/users/alrayyes/following{/other_user}","gists_url":"https://api.github.com/users/alrayyes/gists{/gist_id}","starred_url":"https://api.github.com/users/alrayyes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alrayyes/subscriptions","organizations_url":"https://api.github.com/users/alrayyes/orgs","repos_url":"https://api.github.com/users/alrayyes/repos","events_url":"https://api.github.com/users/alrayyes/events{/privacy}","received_events_url":"https://api.github.com/users/alrayyes/received_events","type":"User","site_admin":false},"labels":[{"id":46429356,"url":"https://api.github.com/repos/spf13/hugo/labels/kind/bug","name":"kind/bug","color":"D49392","default":false},{"id":318108192,"url":"https://api.github.com/repos/spf13/hugo/labels/status/upstream","name":"status/upstream","color":"c7def8","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2016-10-01T23:42:00Z","updated_at":"2016-12-28T04:11:53Z","closed_at":"2016-12-28T04:11:52Z","body":"Hi there,\n\nThe following code produces an error on build:\n\n``` html\n<div class=\"cover-card col-sm-4\" style=\"background: url({{ range last 1 .image }}{{ if index . \"#text\" }}{{ index . \"#text\" }}{{ else  }}http://img2-ak.lst.fm/i/u/300x300/c6f59c1e5e7240a4c0d427abd71f3dbb.png{{ end }}{{ end }}) no-repeat center top;background-size:cover;\">\n```\n\nNamely\n\n``` shell\nStarted building site\nERROR: 2016/10/02 01:27:26 general.go:222: Error while rendering homepage: html/template:theme/index.html:35:116: on range loop re-entry: {{index . \"#text\"}} appears in an ambiguous URL context\n```\n\nThis workaround fixes it for some reason:\n\n``` html\n{{ range last 1 .image }}<div class=\"cover-card col-sm-4\" style=\"background: url({{ if index . \"#text\" }}{{ index . \"#text\" }}{{ else  }}http://img2-ak.lst.fm/i/u/300x300/c6f59c1e5e7240a4c0d427abd71f3dbb.png{{ end }}) no-repeat center top;background-size:cover;\">{{ end }}\n```\n\nFull template code can be found [here](https://github.com/alrayyes/lastfm-hugo-demo-theme/blob/master/layouts/index.html).\n\nIs this a Hugo bug or am I doing something wrong?\n"},"comment":{"url":"https://api.github.com/repos/spf13/hugo/issues/comments/269422849","html_url":"https://github.com/spf13/hugo/issues/2514#issuecomment-269422849","issue_url":"https://api.github.com/repos/spf13/hugo/issues/2514","id":269422849,"user":{"login":"moorereason","id":131056,"avatar_url":"https://avatars.githubusercontent.com/u/131056?v=3","gravatar_id":"","url":"https://api.github.com/users/moorereason","html_url":"https://github.com/moorereason","followers_url":"https://api.github.com/users/moorereason/followers","following_url":"https://api.github.com/users/moorereason/following{/other_user}","gists_url":"https://api.github.com/users/moorereason/gists{/gist_id}","starred_url":"https://api.github.com/users/moorereason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moorereason/subscriptions","organizations_url":"https://api.github.com/users/moorereason/orgs","repos_url":"https://api.github.com/users/moorereason/repos","events_url":"https://api.github.com/users/moorereason/events{/privacy}","received_events_url":"https://api.github.com/users/moorereason/received_events","type":"User","site_admin":false},"created_at":"2016-12-28T04:11:52Z","updated_at":"2016-12-28T04:11:52Z","body":"The issue is that you have a `range` within the `url(...)` context, which can create ambiguities in the URL validation in the Go template engine.  You can work around the issue, as you already discovered, by putting the `range` outside the URL context.\r\n\r\nIt doesn't look like this behavior will be changed upstream, so I'm closing."}}
{"actor":{"display_login":"moorereason"}}