{"action":"created","issue":{"url":"https://api.github.com/repos/expressjs/express-messages/issues/12","labels_url":"https://api.github.com/repos/expressjs/express-messages/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/expressjs/express-messages/issues/12/comments","events_url":"https://api.github.com/repos/expressjs/express-messages/issues/12/events","html_url":"https://github.com/expressjs/express-messages/pull/12","id":90405917,"number":12,"title":"Added customizable messages template","user":{"login":"agraboso","id":7795093,"avatar_url":"https://avatars.githubusercontent.com/u/7795093?v=3","gravatar_id":"","url":"https://api.github.com/users/agraboso","html_url":"https://github.com/agraboso","followers_url":"https://api.github.com/users/agraboso/followers","following_url":"https://api.github.com/users/agraboso/following{/other_user}","gists_url":"https://api.github.com/users/agraboso/gists{/gist_id}","starred_url":"https://api.github.com/users/agraboso/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agraboso/subscriptions","organizations_url":"https://api.github.com/users/agraboso/orgs","repos_url":"https://api.github.com/users/agraboso/repos","events_url":"https://api.github.com/users/agraboso/events{/privacy}","received_events_url":"https://api.github.com/users/agraboso/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":20,"created_at":"2015-06-23T14:34:20Z","updated_at":"2015-07-02T14:49:28Z","closed_at":"2015-06-30T09:02:54Z","pull_request":{"url":"https://api.github.com/repos/expressjs/express-messages/pulls/12","html_url":"https://github.com/expressjs/express-messages/pull/12","diff_url":"https://github.com/expressjs/express-messages/pull/12.diff","patch_url":"https://github.com/expressjs/express-messages/pull/12.patch"},"body":"Addresses #11 in a minimal, backwards-compatible way. This pull request adds two arguments to the `messages()` function, leaving its signature as\r\n```function messages(template, options)```\r\nwhere `template` and `options` are exactly as in Express's `res.render(template, options)`. In fact, it uses the latter function internally, and so makes use of Express's handling of templating engines and views.\r\n\r\nIt works as follows:\r\n1. If `req.flash()` returns the empty array, `messages()` outputs an empty string.\r\n2. If `req.flash()` returns a non-empty array, then:\r\n  * if the `template` argument is falsy (undefined or an empty string), `messages()` produces the exact same output as before --- preserving backwards-compatibility;\r\n  * if the `template` argument is a valid template filename, `messages()` compiles the template with the given `options`;\r\n  * if the `template` is truthy but not a valid template filename, `messages()` outputs an empty string (i.e., it fails silently).\r\n\r\nTests pass, but I haven't written any new ones --- I'd rather wait and see if this might be merged or not ---, but I have been playing with it, and it works as advertised.\r\n\r\nThe code draws heavily from @artcommacode's answer in #11."},"comment":{"url":"https://api.github.com/repos/expressjs/express-messages/issues/comments/118056359","html_url":"https://github.com/expressjs/express-messages/pull/12#issuecomment-118056359","issue_url":"https://api.github.com/repos/expressjs/express-messages/issues/12","id":118056359,"user":{"login":"artcommacode","id":1155516,"avatar_url":"https://avatars.githubusercontent.com/u/1155516?v=3","gravatar_id":"","url":"https://api.github.com/users/artcommacode","html_url":"https://github.com/artcommacode","followers_url":"https://api.github.com/users/artcommacode/followers","following_url":"https://api.github.com/users/artcommacode/following{/other_user}","gists_url":"https://api.github.com/users/artcommacode/gists{/gist_id}","starred_url":"https://api.github.com/users/artcommacode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/artcommacode/subscriptions","organizations_url":"https://api.github.com/users/artcommacode/orgs","repos_url":"https://api.github.com/users/artcommacode/repos","events_url":"https://api.github.com/users/artcommacode/events{/privacy}","received_events_url":"https://api.github.com/users/artcommacode/received_events","type":"User","site_admin":false},"created_at":"2015-07-02T14:49:27Z","updated_at":"2015-07-02T14:49:27Z","body":"Thanks again Doug."}}