{"action":"created","issue":{"url":"https://api.github.com/repos/haml/haml/issues/801","labels_url":"https://api.github.com/repos/haml/haml/issues/801/labels{/name}","comments_url":"https://api.github.com/repos/haml/haml/issues/801/comments","events_url":"https://api.github.com/repos/haml/haml/issues/801/events","html_url":"https://github.com/haml/haml/pull/801","id":42739158,"number":801,"title":"Blocks become more useful","user":{"login":"Iazel","id":1616917,"avatar_url":"https://avatars.githubusercontent.com/u/1616917?v=3","gravatar_id":"","url":"https://api.github.com/users/Iazel","html_url":"https://github.com/Iazel","followers_url":"https://api.github.com/users/Iazel/followers","following_url":"https://api.github.com/users/Iazel/following{/other_user}","gists_url":"https://api.github.com/users/Iazel/gists{/gist_id}","starred_url":"https://api.github.com/users/Iazel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Iazel/subscriptions","organizations_url":"https://api.github.com/users/Iazel/orgs","repos_url":"https://api.github.com/users/Iazel/repos","events_url":"https://api.github.com/users/Iazel/events{/privacy}","received_events_url":"https://api.github.com/users/Iazel/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/haml/haml/milestones/2","html_url":"https://github.com/haml/haml/milestones/6.0","labels_url":"https://api.github.com/repos/haml/haml/milestones/2/labels","id":132191,"number":2,"title":"6.0","description":"","creator":{"login":"norman","id":5042,"avatar_url":"https://avatars.githubusercontent.com/u/5042?v=3","gravatar_id":"","url":"https://api.github.com/users/norman","html_url":"https://github.com/norman","followers_url":"https://api.github.com/users/norman/followers","following_url":"https://api.github.com/users/norman/following{/other_user}","gists_url":"https://api.github.com/users/norman/gists{/gist_id}","starred_url":"https://api.github.com/users/norman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/norman/subscriptions","organizations_url":"https://api.github.com/users/norman/orgs","repos_url":"https://api.github.com/users/norman/repos","events_url":"https://api.github.com/users/norman/events{/privacy}","received_events_url":"https://api.github.com/users/norman/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":2,"state":"open","created_at":"2012-06-15T01:20:47Z","updated_at":"2014-12-18T14:44:01Z","due_on":"2016-01-01T03:00:00Z","closed_at":null},"comments":21,"created_at":"2014-09-15T03:33:46Z","updated_at":"2015-06-08T07:59:05Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/haml/haml/pulls/801","html_url":"https://github.com/haml/haml/pull/801","diff_url":"https://github.com/haml/haml/pull/801.diff","patch_url":"https://github.com/haml/haml/pull/801.patch"},"body":"HAML (and all the other template manager I've seen) have a big lack: blocks. Using a block should be more straightforward, and as a user, given this context:\r\n```ruby\r\nclass Context\r\n  def em\r\n    \"<em>#{yield}</em>\"\r\n  end\r\nend\r\n```\r\n\r\nI expect this code:\r\n```haml\r\nHello\r\n= em do\r\n   World\r\n!!\r\n```\r\n\r\nTo produce something like:\r\n```html\r\nHello\r\n<em>World</em>\r\n!!\r\n```\r\n\r\nAnd not:\r\n```html\r\nHello\r\nWorld\r\n<em>Hello\r\nWorld</em>\r\n!!\r\n```\r\n\r\nYes, I know, for case like this we can use `capture_haml`, but this approach is really bad and cause a lot of issues. For example, if I use a [ViewModel](https://github.com/apotonick/cells) and want to use some pretty nice rails gem like `simple_form_for`, the only way is to clobber the actual context with all the method needed. However, if blocks work as expected, I could use the main `ActionView` object just like an helper container.\r\nThis is just some case, but I'm sure fixing this will give a lot more flexibility, plus I can't imagine a method that needs a block but doesn't use its content.\r\n\r\nHence, I've made this patch. If you like it, we could also *eradicate* a lot of helper method that become futile, and replace all the `capture_haml` with just a `yield` and `=`. I think this should also speed up the compiled code.\r\n\r\n**There's only 2 test that I've skipped because I don't think they are really useful and it's quite hard to green them maintaining the same HAML source** (the same result can be achieved with a small modification of it).\r\n\r\nHope you find this as useful as I do :)"},"comment":{"url":"https://api.github.com/repos/haml/haml/issues/comments/109896084","html_url":"https://github.com/haml/haml/pull/801#issuecomment-109896084","issue_url":"https://api.github.com/repos/haml/haml/issues/801","id":109896084,"user":{"login":"apotonick","id":10406,"avatar_url":"https://avatars.githubusercontent.com/u/10406?v=3","gravatar_id":"","url":"https://api.github.com/users/apotonick","html_url":"https://github.com/apotonick","followers_url":"https://api.github.com/users/apotonick/followers","following_url":"https://api.github.com/users/apotonick/following{/other_user}","gists_url":"https://api.github.com/users/apotonick/gists{/gist_id}","starred_url":"https://api.github.com/users/apotonick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apotonick/subscriptions","organizations_url":"https://api.github.com/users/apotonick/orgs","repos_url":"https://api.github.com/users/apotonick/repos","events_url":"https://api.github.com/users/apotonick/events{/privacy}","received_events_url":"https://api.github.com/users/apotonick/received_events","type":"User","site_admin":false},"created_at":"2015-06-08T07:59:04Z","updated_at":"2015-06-08T07:59:04Z","body":"Hi @norman, I'd be happy to help! We could move a lot of Rails patches to optional modules (for older Rails), so we can get rid of them once we drop support.\r\n\r\nAlso - I started to get into performance. Anything planned here? \r\n\r\nThanks!!! :heart: "}}