{"action":"created","issue":{"url":"https://api.github.com/repos/keeps/roda-in/issues/140","repository_url":"https://api.github.com/repos/keeps/roda-in","labels_url":"https://api.github.com/repos/keeps/roda-in/issues/140/labels{/name}","comments_url":"https://api.github.com/repos/keeps/roda-in/issues/140/comments","events_url":"https://api.github.com/repos/keeps/roda-in/issues/140/events","html_url":"https://github.com/keeps/roda-in/issues/140","id":147135612,"number":140,"title":"The template system should be able to differentiate between auto-generated values and user variables","user":{"login":"jmaferreira","id":3181302,"avatar_url":"https://avatars.githubusercontent.com/u/3181302?v=3","gravatar_id":"","url":"https://api.github.com/users/jmaferreira","html_url":"https://github.com/jmaferreira","followers_url":"https://api.github.com/users/jmaferreira/followers","following_url":"https://api.github.com/users/jmaferreira/following{/other_user}","gists_url":"https://api.github.com/users/jmaferreira/gists{/gist_id}","starred_url":"https://api.github.com/users/jmaferreira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmaferreira/subscriptions","organizations_url":"https://api.github.com/users/jmaferreira/orgs","repos_url":"https://api.github.com/users/jmaferreira/repos","events_url":"https://api.github.com/users/jmaferreira/events{/privacy}","received_events_url":"https://api.github.com/users/jmaferreira/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/keeps/roda-in/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":{"login":"adrapereira","id":4313971,"avatar_url":"https://avatars.githubusercontent.com/u/4313971?v=3","gravatar_id":"","url":"https://api.github.com/users/adrapereira","html_url":"https://github.com/adrapereira","followers_url":"https://api.github.com/users/adrapereira/followers","following_url":"https://api.github.com/users/adrapereira/following{/other_user}","gists_url":"https://api.github.com/users/adrapereira/gists{/gist_id}","starred_url":"https://api.github.com/users/adrapereira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrapereira/subscriptions","organizations_url":"https://api.github.com/users/adrapereira/orgs","repos_url":"https://api.github.com/users/adrapereira/repos","events_url":"https://api.github.com/users/adrapereira/events{/privacy}","received_events_url":"https://api.github.com/users/adrapereira/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/keeps/roda-in/milestones/5","html_url":"https://github.com/keeps/roda-in/milestones/2.0.0","labels_url":"https://api.github.com/repos/keeps/roda-in/milestones/5/labels","id":1463032,"number":5,"title":"2.0.0","description":"Final version 2 release ready for DGLAB.","creator":{"login":"jmaferreira","id":3181302,"avatar_url":"https://avatars.githubusercontent.com/u/3181302?v=3","gravatar_id":"","url":"https://api.github.com/users/jmaferreira","html_url":"https://github.com/jmaferreira","followers_url":"https://api.github.com/users/jmaferreira/followers","following_url":"https://api.github.com/users/jmaferreira/following{/other_user}","gists_url":"https://api.github.com/users/jmaferreira/gists{/gist_id}","starred_url":"https://api.github.com/users/jmaferreira/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmaferreira/subscriptions","organizations_url":"https://api.github.com/users/jmaferreira/orgs","repos_url":"https://api.github.com/users/jmaferreira/repos","events_url":"https://api.github.com/users/jmaferreira/events{/privacy}","received_events_url":"https://api.github.com/users/jmaferreira/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":3,"state":"open","created_at":"2015-12-16T11:27:38Z","updated_at":"2016-04-09T16:15:56Z","due_on":"2016-05-31T22:00:00Z","closed_at":null},"comments":1,"created_at":"2016-04-09T15:01:00Z","updated_at":"2016-04-10T12:15:17Z","closed_at":null,"body":"For example, currently the {{now}} variable is reserved for a auto date generator.\r\n\r\nThis are special value generators, not variable numbers. So, something like the following is essencial:\r\n\r\n<date>{{Date default=\"Autovalue.now\"}}</date>\r\n\r\nMeaning that we should differentiate between the variable name (that is shown on the form as a label) and the value (which can be user input or auto generated by the app). Auto generated values should have a prefix such as \"System.\" or \"Autovalue.\".\r\n"},"comment":{"url":"https://api.github.com/repos/keeps/roda-in/issues/comments/207975495","html_url":"https://github.com/keeps/roda-in/issues/140#issuecomment-207975495","issue_url":"https://api.github.com/repos/keeps/roda-in/issues/140","id":207975495,"user":{"login":"luis100","id":631728,"avatar_url":"https://avatars.githubusercontent.com/u/631728?v=3","gravatar_id":"","url":"https://api.github.com/users/luis100","html_url":"https://github.com/luis100","followers_url":"https://api.github.com/users/luis100/followers","following_url":"https://api.github.com/users/luis100/following{/other_user}","gists_url":"https://api.github.com/users/luis100/gists{/gist_id}","starred_url":"https://api.github.com/users/luis100/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/luis100/subscriptions","organizations_url":"https://api.github.com/users/luis100/orgs","repos_url":"https://api.github.com/users/luis100/repos","events_url":"https://api.github.com/users/luis100/events{/privacy}","received_events_url":"https://api.github.com/users/luis100/received_events","type":"User","site_admin":false},"created_at":"2016-04-10T12:15:17Z","updated_at":"2016-04-10T12:15:17Z","body":"Mustache and Handlebars support scope, so you can add a namespace to the context that is sent to the template. Right now the context is a hashmap, but you can replace it with a more complex context like:\r\n\r\n```\r\npublic class TemplateContext {\r\n  public final Map<String,String> system;\r\n  public final Map<String,String> user;\r\n}\r\n...\r\n```\r\n\r\nAnd then use them in the templates we can say:\r\n```\r\n{{user.date}}{{^user.date}}{{system.now}}{{/user.date}}\r\n```\r\n\r\nPlease note that Mustache are **logic-less templates** so their functionality is quite limited. But Handlebars allow to create helpers which can be functions that receive any argument within the mustache var `{{#helper arg1 arg2}}` so we can extend the templating system with some functionalities if needed."}}