{"action":"created","issue":{"url":"https://api.github.com/repos/henix/slt2/issues/9","repository_url":"https://api.github.com/repos/henix/slt2","labels_url":"https://api.github.com/repos/henix/slt2/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/henix/slt2/issues/9/comments","events_url":"https://api.github.com/repos/henix/slt2/issues/9/events","html_url":"https://github.com/henix/slt2/issues/9","id":127961661,"number":9,"title":"Don't output empty lines for control flow template arguments","user":{"login":"FSMaxB","id":4294942,"avatar_url":"https://avatars.githubusercontent.com/u/4294942?v=3","gravatar_id":"","url":"https://api.github.com/users/FSMaxB","html_url":"https://github.com/FSMaxB","followers_url":"https://api.github.com/users/FSMaxB/followers","following_url":"https://api.github.com/users/FSMaxB/following{/other_user}","gists_url":"https://api.github.com/users/FSMaxB/gists{/gist_id}","starred_url":"https://api.github.com/users/FSMaxB/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FSMaxB/subscriptions","organizations_url":"https://api.github.com/users/FSMaxB/orgs","repos_url":"https://api.github.com/users/FSMaxB/repos","events_url":"https://api.github.com/users/FSMaxB/events{/privacy}","received_events_url":"https://api.github.com/users/FSMaxB/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/henix/slt2/labels/enhancement","name":"enhancement","color":"006b75"}],"state":"open","locked":false,"assignee":{"login":"henix","id":288251,"avatar_url":"https://avatars.githubusercontent.com/u/288251?v=3","gravatar_id":"","url":"https://api.github.com/users/henix","html_url":"https://github.com/henix","followers_url":"https://api.github.com/users/henix/followers","following_url":"https://api.github.com/users/henix/following{/other_user}","gists_url":"https://api.github.com/users/henix/gists{/gist_id}","starred_url":"https://api.github.com/users/henix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henix/subscriptions","organizations_url":"https://api.github.com/users/henix/orgs","repos_url":"https://api.github.com/users/henix/repos","events_url":"https://api.github.com/users/henix/events{/privacy}","received_events_url":"https://api.github.com/users/henix/received_events","type":"User","site_admin":false},"milestone":null,"comments":5,"created_at":"2016-01-21T16:21:11Z","updated_at":"2016-02-05T16:53:27Z","closed_at":null,"body":"I noticed, that when I write something like this:\r\n```\r\nsome text\r\n#{for i = 1, 4 do}#\r\n#{= i}#\r\n#{end}#\r\nsome more text\r\n```\r\n\r\nThe output is something like:\r\n```\r\nsome text\r\n\r\n1\r\n2\r\n3\r\n4\r\n\r\nsome more text\r\n```\r\n\r\nIf I don't want these two empty lines, I would have to write everything into one line like:\r\n```\r\n#{for i = 1, 4 do}##{= i}##{end}#\r\n```\r\nThis is really ugly to read though. Would you be willing to accept a pull request that would check if a line only contains a control flow template parameter and, if so, doesn't emit those empty lines. (This could be hidden behind some kind of configuration parameter if necessary).\r\n\r\nIf this is a feature that you think will fit into the scope of slt2, I'd take a look if it is possible to implement this."},"comment":{"url":"https://api.github.com/repos/henix/slt2/issues/comments/180437642","html_url":"https://github.com/henix/slt2/issues/9#issuecomment-180437642","issue_url":"https://api.github.com/repos/henix/slt2/issues/9","id":180437642,"user":{"login":"henix","id":288251,"avatar_url":"https://avatars.githubusercontent.com/u/288251?v=3","gravatar_id":"","url":"https://api.github.com/users/henix","html_url":"https://github.com/henix","followers_url":"https://api.github.com/users/henix/followers","following_url":"https://api.github.com/users/henix/following{/other_user}","gists_url":"https://api.github.com/users/henix/gists{/gist_id}","starred_url":"https://api.github.com/users/henix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/henix/subscriptions","organizations_url":"https://api.github.com/users/henix/orgs","repos_url":"https://api.github.com/users/henix/repos","events_url":"https://api.github.com/users/henix/events{/privacy}","received_events_url":"https://api.github.com/users/henix/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T16:53:26Z","updated_at":"2016-02-05T16:53:26Z","body":"Your idea is very similar to mine: adding a lexing phase, just like what compilers do. And yes, `include_fold` and `loadstring` have a common structure that should be extracted into a function.\r\n\r\nBut for me, I prefer there would be only 2 types of chunks:\r\n\r\n1. Template (which delimited by `start_tag` and `end_tag`)\r\n2. Normal text\r\n\r\nAfter `parse`, you will get a list of chunks. Then `trim_blocks` can be implemented by modifying normal text chunks before and after current template chunk.\r\n\r\nI think you can just implement `trim_blocks` in the current direction of #10 (if you want to use it in your projects in a short time). It's almost finished. If you did, I would release a v1.1. Then I will take care of the refactor and release a v2.0.\r\n\r\nMy current plan is the API will be changed in v2.0. `loadstring(tmpl, start_tag, end_tag, tmpl_name, trim_blocks)` should be changed to `loadstring(tmpl, tmpl_name, options)` or something like that. `options` is a table, containing fields like `start_tag`, `end_tag`, `trim_blocks`. Because after adding an option, the function's signature is not so readable.\r\n\r\nAnd #12 may also be considered in v2.0 (or v2.1)."}}