{"action":"created","issue":{"url":"https://api.github.com/repos/mde/ejs/issues/252","repository_url":"https://api.github.com/repos/mde/ejs","labels_url":"https://api.github.com/repos/mde/ejs/issues/252/labels{/name}","comments_url":"https://api.github.com/repos/mde/ejs/issues/252/comments","events_url":"https://api.github.com/repos/mde/ejs/issues/252/events","html_url":"https://github.com/mde/ejs/issues/252","id":222110120,"number":252,"title":"block/template/extend support for ejs","user":{"login":"huxia","id":228669,"avatar_url":"https://avatars0.githubusercontent.com/u/228669?v=3","gravatar_id":"","url":"https://api.github.com/users/huxia","html_url":"https://github.com/huxia","followers_url":"https://api.github.com/users/huxia/followers","following_url":"https://api.github.com/users/huxia/following{/other_user}","gists_url":"https://api.github.com/users/huxia/gists{/gist_id}","starred_url":"https://api.github.com/users/huxia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/huxia/subscriptions","organizations_url":"https://api.github.com/users/huxia/orgs","repos_url":"https://api.github.com/users/huxia/repos","events_url":"https://api.github.com/users/huxia/events{/privacy}","received_events_url":"https://api.github.com/users/huxia/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-04-17T10:52:14Z","updated_at":"2017-07-03T17:24:03Z","closed_at":null,"body":"Currently ejs doesn't have any block/template/extend features.\r\n\r\n### existing solutions:\r\n> https://github.com/seqs/ejs-blocks\r\n>> neat javascript grammar, however it only support raw strings as block content.\r\n\r\n> https://github.com/tj/ejs/pull/142\r\n>> it invents several preprocessor directives like `<%block header%>`, `<%/block header%>` `<%+ template%>`, thus not very easy to learn, this is against ejs's design goals. \r\n\r\n### my approach:\r\n\r\nblock implementation (home.ejs):\r\n```ejs\r\n<!-- define block contents by functions, it should be able to access the same locals data & context -->\r\n<% var header = block(function() { %>\r\n<%- include('./include.css') %>\r\n<title>Hello <%= name %></title>\r\n<% }) -%>\r\n<% var body = block(function() { %>\r\n<div>\r\n  you have an message: <%= message.toLowerCase() %>\r\n</div>\r\n<% }) -%>\r\n\r\n<!-- a single \"include\" finally, and its contents are passed by locals -->\r\n<%- include('./layout', {body, header}) %>\r\n```\r\n\r\n\r\n\r\nblock declaration (layout.ejs):\r\n```ejs\r\n<html>\r\n    <head>\r\n        <!-- \"blocks\" is a built in function to check whether a specific block is been implemented -->\r\n        <% if (!blocks(header)) { %>\r\n            <title>default title</title>\r\n        <% } %>\r\n    </head>\r\n    <body>\r\n        <h1>This is a layout</h1>\r\n        <% blocks(body) %>\r\n    </body>\r\n</html>\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/mde/ejs/issues/comments/312698709","html_url":"https://github.com/mde/ejs/issues/252#issuecomment-312698709","issue_url":"https://api.github.com/repos/mde/ejs/issues/252","id":312698709,"user":{"login":"rossrossp","id":6325131,"avatar_url":"https://avatars0.githubusercontent.com/u/6325131?v=3","gravatar_id":"","url":"https://api.github.com/users/rossrossp","html_url":"https://github.com/rossrossp","followers_url":"https://api.github.com/users/rossrossp/followers","following_url":"https://api.github.com/users/rossrossp/following{/other_user}","gists_url":"https://api.github.com/users/rossrossp/gists{/gist_id}","starred_url":"https://api.github.com/users/rossrossp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rossrossp/subscriptions","organizations_url":"https://api.github.com/users/rossrossp/orgs","repos_url":"https://api.github.com/users/rossrossp/repos","events_url":"https://api.github.com/users/rossrossp/events{/privacy}","received_events_url":"https://api.github.com/users/rossrossp/received_events","type":"User","site_admin":false},"created_at":"2017-07-03T17:24:03Z","updated_at":"2017-07-03T17:24:03Z","body":"Is anything happening with this?"}}
{"actor":{"display_login":"rossrossp"}}