{"action":"created","issue":{"url":"https://api.github.com/repos/jadejs/jade/issues/1930","labels_url":"https://api.github.com/repos/jadejs/jade/issues/1930/labels{/name}","comments_url":"https://api.github.com/repos/jadejs/jade/issues/1930/comments","events_url":"https://api.github.com/repos/jadejs/jade/issues/1930/events","html_url":"https://github.com/jadejs/jade/issues/1930","id":68128381,"number":1930,"title":"Variables is defined before `extends` keyword couldn't be used (got `undefined`)","user":{"login":"hoangddt","id":9208429,"avatar_url":"https://avatars.githubusercontent.com/u/9208429?v=3","gravatar_id":"","url":"https://api.github.com/users/hoangddt","html_url":"https://github.com/hoangddt","followers_url":"https://api.github.com/users/hoangddt/followers","following_url":"https://api.github.com/users/hoangddt/following{/other_user}","gists_url":"https://api.github.com/users/hoangddt/gists{/gist_id}","starred_url":"https://api.github.com/users/hoangddt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hoangddt/subscriptions","organizations_url":"https://api.github.com/users/hoangddt/orgs","repos_url":"https://api.github.com/users/hoangddt/repos","events_url":"https://api.github.com/users/hoangddt/events{/privacy}","received_events_url":"https://api.github.com/users/hoangddt/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jadejs/jade/labels/Error%20Reporting","name":"Error Reporting","color":"444444"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-04-13T15:36:43Z","updated_at":"2015-06-12T14:28:44Z","closed_at":"2015-06-12T14:28:44Z","body":"Hi, I got this problem.\r\nThe variable I define before `extends` keyword can't be used (got `undefined`). \r\nHere is the code snippet\r\n\r\n```jade\r\n//- simplePageTemplate.jade\r\n- var a = \"Hello from variable\"\r\ndoctype\r\nhtml\r\n\thead\r\n\t\tblock title\r\n\t\t\ttitle This is default title\r\n\t\tblock head\r\n\tbody\r\n\t\th2 #{a}\r\n\t\tblock content\r\n```\r\n\r\n\r\n```jade\r\n//- index.jade\r\n- var config = \"Hello from variable before extends\"\r\n\r\nextends simplePageTemplate\r\n\r\nblock content\r\n\tp #{config}\r\n\t#{config}\r\n```\r\n\r\nThe output `index.html`\r\n```html\r\n<!DOCTYPE html>\r\n<html>\r\n  <head>\r\n    <title>This is default title</title>\r\n  </head>\r\n  <body>\r\n    <h2>Hello from variable</h2>\r\n    <p></p>\r\n    <undefined></undefined>\r\n  </body>\r\n</html>\r\n```\r\n\r\nWhy the variable couldn't be used inside a file have extends keyword?\r\nHow to solve that problem, any solution?\r\nSorry for my bad English!"},"comment":{"url":"https://api.github.com/repos/jadejs/jade/issues/comments/111512728","html_url":"https://github.com/jadejs/jade/issues/1930#issuecomment-111512728","issue_url":"https://api.github.com/repos/jadejs/jade/issues/1930","id":111512728,"user":{"login":"ForbesLindesay","id":1260646,"avatar_url":"https://avatars.githubusercontent.com/u/1260646?v=3","gravatar_id":"","url":"https://api.github.com/users/ForbesLindesay","html_url":"https://github.com/ForbesLindesay","followers_url":"https://api.github.com/users/ForbesLindesay/followers","following_url":"https://api.github.com/users/ForbesLindesay/following{/other_user}","gists_url":"https://api.github.com/users/ForbesLindesay/gists{/gist_id}","starred_url":"https://api.github.com/users/ForbesLindesay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ForbesLindesay/subscriptions","organizations_url":"https://api.github.com/users/ForbesLindesay/orgs","repos_url":"https://api.github.com/users/ForbesLindesay/repos","events_url":"https://api.github.com/users/ForbesLindesay/events{/privacy}","received_events_url":"https://api.github.com/users/ForbesLindesay/received_events","type":"User","site_admin":false},"created_at":"2015-06-12T14:28:44Z","updated_at":"2015-06-12T14:28:44Z","body":"You need to put the variable declaration inside a block:\r\n\r\n```jade\r\n//- simplePageTemplate.jade\r\n- var a = \"Hello from variable\"\r\nblock config\r\ndoctype\r\nhtml\r\n    head\r\n        block title\r\n            title This is default title\r\n        block head\r\n    body\r\n        h2 #{a}\r\n        block content\r\n```\r\n\r\n```jade\r\n//- index.jade\r\nextends simplePageTemplate\r\n\r\nblock config\r\n  - var config = \"Hello from variable before extends\"\r\nblock content\r\n    p #{config}\r\n    #{config}\r\n```\r\n\r\nThis will give you a proper error message in v2.0.0"}}