{"action":"created","issue":{"url":"https://api.github.com/repos/jadejs/jade/issues/2030","labels_url":"https://api.github.com/repos/jadejs/jade/issues/2030/labels{/name}","comments_url":"https://api.github.com/repos/jadejs/jade/issues/2030/comments","events_url":"https://api.github.com/repos/jadejs/jade/issues/2030/events","html_url":"https://github.com/jadejs/jade/issues/2030","id":98634168,"number":2030,"title":"Possible solution to allowing dynamic include","user":{"login":"smaili","id":4451986,"avatar_url":"https://avatars.githubusercontent.com/u/4451986?v=3","gravatar_id":"","url":"https://api.github.com/users/smaili","html_url":"https://github.com/smaili","followers_url":"https://api.github.com/users/smaili/followers","following_url":"https://api.github.com/users/smaili/following{/other_user}","gists_url":"https://api.github.com/users/smaili/gists{/gist_id}","starred_url":"https://api.github.com/users/smaili/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smaili/subscriptions","organizations_url":"https://api.github.com/users/smaili/orgs","repos_url":"https://api.github.com/users/smaili/repos","events_url":"https://api.github.com/users/smaili/events{/privacy}","received_events_url":"https://api.github.com/users/smaili/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jadejs/jade/labels/includes","name":"includes","color":"49006E"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-08-02T20:18:14Z","updated_at":"2015-09-16T04:05:47Z","closed_at":null,"body":"There's so many issues that are open regarding this I honestly am not sure which one (if any) is the main/active one so I'm creating a new ticket that I hope may offer a solution :)\r\n\r\nAs I understand correctly, the reason for currently not having the ability for dynamic includes is due to compilation.  Assuming that is correct, I would like to propose allowing the use of dynamic include with the constraint that you must give some sort of compiler annotation that provides a list of all possible values of that dynamic include.\r\n\r\nFor example, say I have the template `main.jade`:\r\n\r\n```Jade\r\n//- main.jade\r\n-\r\n    var name = '';\r\n    if ( input === 'a' ) name = 'a';\r\n    else if ( input === 'b' ) name = 'b';\r\n    else if ( input === 'c' ) name = 'c';\r\n    else name = 'd';\r\n\r\ninclude /templates/#{ name }\r\n```\r\n\r\nIn order to let the compiler know all of the possible files that may be included, we just include some kind of special annotation.\r\n```Jade\r\n//- main.jade\r\n-\r\n    var name = '';\r\n    if ( input === 'a' ) name = 'a';\r\n    else if ( input === 'b' ) name = 'b';\r\n    else if ( input === 'c' ) name = 'c';\r\n    else name = 'd';\r\n\r\n//- Give the compiler key/value list of possible values for each variable used in the include\r\ninclude /templates/#{ name }//-{ name: [ 'a', 'b', 'c', 'd' ] }\r\n```"},"comment":{"url":"https://api.github.com/repos/jadejs/jade/issues/comments/140620922","html_url":"https://github.com/jadejs/jade/issues/2030#issuecomment-140620922","issue_url":"https://api.github.com/repos/jadejs/jade/issues/2030","id":140620922,"user":{"login":"nullivex","id":2321375,"avatar_url":"https://avatars.githubusercontent.com/u/2321375?v=3","gravatar_id":"","url":"https://api.github.com/users/nullivex","html_url":"https://github.com/nullivex","followers_url":"https://api.github.com/users/nullivex/followers","following_url":"https://api.github.com/users/nullivex/following{/other_user}","gists_url":"https://api.github.com/users/nullivex/gists{/gist_id}","starred_url":"https://api.github.com/users/nullivex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nullivex/subscriptions","organizations_url":"https://api.github.com/users/nullivex/orgs","repos_url":"https://api.github.com/users/nullivex/repos","events_url":"https://api.github.com/users/nullivex/events{/privacy}","received_events_url":"https://api.github.com/users/nullivex/received_events","type":"User","site_admin":false},"created_at":"2015-09-16T04:05:47Z","updated_at":"2015-09-16T04:05:47Z","body":"@ForbesLindesay Alright, that setting works great. Thanks for pointing that out.\r\n\r\nAlso I just want to say thank you to Jade. The only template engine I have ever used that didnt make me want to make my own (including a few of my own that still didnt accomplish it).\r\n\r\nTHANK YOU!!"}}