{"action":"created","issue":{"url":"https://api.github.com/repos/vapor/vapor/issues/680","repository_url":"https://api.github.com/repos/vapor/vapor","labels_url":"https://api.github.com/repos/vapor/vapor/issues/680/labels{/name}","comments_url":"https://api.github.com/repos/vapor/vapor/issues/680/comments","events_url":"https://api.github.com/repos/vapor/vapor/issues/680/events","html_url":"https://github.com/vapor/vapor/issues/680","id":186767897,"number":680,"title":"Leaf: negating statements","user":{"login":"4np","id":1049693,"avatar_url":"https://avatars.githubusercontent.com/u/1049693?v=3","gravatar_id":"","url":"https://api.github.com/users/4np","html_url":"https://github.com/4np","followers_url":"https://api.github.com/users/4np/followers","following_url":"https://api.github.com/users/4np/following{/other_user}","gists_url":"https://api.github.com/users/4np/gists{/gist_id}","starred_url":"https://api.github.com/users/4np/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/4np/subscriptions","organizations_url":"https://api.github.com/users/4np/orgs","repos_url":"https://api.github.com/users/4np/repos","events_url":"https://api.github.com/users/4np/events{/privacy}","received_events_url":"https://api.github.com/users/4np/received_events","type":"User","site_admin":false},"labels":[{"id":375450699,"url":"https://api.github.com/repos/vapor/vapor/labels/reviewing","name":"reviewing","color":"d4c5f9","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-02T10:49:28Z","updated_at":"2016-11-02T17:45:04Z","closed_at":null,"body":"# Feature, Enhancement, or Optimization\r\n# Negating statements and conditions\r\n- Author(s): [Jeroen Wesbeek](https://github.com/4np)\r\n- Subject: [Leaf templating](https://vapor.github.io/documentation/guide/leaf.html) 🍃\r\n\r\n## Introduction\r\n\r\nWhile it is currently possible to use `if`, `then`, `else` statements (see the [documentation](https://vapor.github.io/documentation/guide/leaf.html#if---else)), you can only use statements that evaluate to true. It would be great to use negating statements.\r\n\r\n```\r\n#if(entering) {\r\n  Hello, there!\r\n} ##if(leaving) {\r\n  Goodbye!\r\n} ##else() {\r\n  I've been here the whole time.\r\n}\r\n```\r\n\r\n## Motivation\r\n\r\nEvaluating false statements currently requires you to write dummy else constructs which are rather inconvenient:\r\n\r\n```\r\n#loop(elements, \"element\") {\r\n    <option value=\"#(element.id)\" #if(element.enabled) { } ##else() { disabled }>#(element.name)</option>\r\n}\r\n```\r\n\r\nAdditionally a condition containing an evaluation (e.g. `#if(device.enabled == false) { disabled }`) also does not work.\r\n\r\n## Proposed solution\r\n\r\nIntroduce negating statements:\r\n\r\n```\r\n#if(!element.enabled)\r\n```\r\n\r\nApplying this to the above example this would lead to the more convenient code:\r\n\r\n```\r\n#loop(elements, \"element\") {\r\n    <option value=\"#(element.id)\" #if(!element.enabled) { disabled }>#(element.name)</option>\r\n}\r\n```\r\n\r\n## Extra\r\n\r\nIt would also be great if evaluating expressions would work so that `#if(device.enabled == false) { disabled }` would work as well."},"comment":{"url":"https://api.github.com/repos/vapor/vapor/issues/comments/257943038","html_url":"https://github.com/vapor/vapor/issues/680#issuecomment-257943038","issue_url":"https://api.github.com/repos/vapor/vapor/issues/680","id":257943038,"user":{"login":"tannernelson","id":1342803,"avatar_url":"https://avatars.githubusercontent.com/u/1342803?v=3","gravatar_id":"","url":"https://api.github.com/users/tannernelson","html_url":"https://github.com/tannernelson","followers_url":"https://api.github.com/users/tannernelson/followers","following_url":"https://api.github.com/users/tannernelson/following{/other_user}","gists_url":"https://api.github.com/users/tannernelson/gists{/gist_id}","starred_url":"https://api.github.com/users/tannernelson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tannernelson/subscriptions","organizations_url":"https://api.github.com/users/tannernelson/orgs","repos_url":"https://api.github.com/users/tannernelson/repos","events_url":"https://api.github.com/users/tannernelson/events{/privacy}","received_events_url":"https://api.github.com/users/tannernelson/received_events","type":"User","site_admin":false},"created_at":"2016-11-02T17:45:04Z","updated_at":"2016-11-02T17:45:04Z","body":"Off the top of my head `!`, `==`, etc look like Leaf 2.0 features to me.\r\n\r\nSomething like `#ifNot()` and `#notEqual()` would work for `!`. We have `#if` and `#equal()`."}}
{"actor":{"display_login":"tannernelson"}}