{"action":"created","issue":{"url":"https://api.github.com/repos/mavoweb/mavo/issues/161","repository_url":"https://api.github.com/repos/mavoweb/mavo","labels_url":"https://api.github.com/repos/mavoweb/mavo/issues/161/labels{/name}","comments_url":"https://api.github.com/repos/mavoweb/mavo/issues/161/comments","events_url":"https://api.github.com/repos/mavoweb/mavo/issues/161/events","html_url":"https://github.com/mavoweb/mavo/issues/161","id":224320978,"number":161,"title":"Mavo functions","user":{"login":"LeaVerou","id":175836,"avatar_url":"https://avatars1.githubusercontent.com/u/175836?v=4","gravatar_id":"","url":"https://api.github.com/users/LeaVerou","html_url":"https://github.com/LeaVerou","followers_url":"https://api.github.com/users/LeaVerou/followers","following_url":"https://api.github.com/users/LeaVerou/following{/other_user}","gists_url":"https://api.github.com/users/LeaVerou/gists{/gist_id}","starred_url":"https://api.github.com/users/LeaVerou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeaVerou/subscriptions","organizations_url":"https://api.github.com/users/LeaVerou/orgs","repos_url":"https://api.github.com/users/LeaVerou/repos","events_url":"https://api.github.com/users/LeaVerou/events{/privacy}","received_events_url":"https://api.github.com/users/LeaVerou/received_events","type":"User","site_admin":false},"labels":[{"id":577432034,"url":"https://api.github.com/repos/mavoweb/mavo/labels/discussion","name":"discussion","color":"0052cc","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-04-26T01:56:09Z","updated_at":"2017-12-17T21:17:39Z","closed_at":null,"author_association":"OWNER","body":"As a Mavo author, I've often felt the need to define my own expression functions, a privilege currently only available to those who know JS. For example, if you have multiple date properties, that you want to share the same format. Or, an expression that generates a custom link based on data. Or transforming data so I can render them on another template using `mv-value`. The possibilities are endless. If I can *use* expression functions, I should be able to define my own in terms of expressions and HTML.\r\n\r\nI'm thinking of something like:\r\n\r\n```html\r\n<mv-function property=\"myDateFormat\">\r\n    <meta property=\"output\" content=\"[month(input)] [ordinal(day(input))], [year(input)]\">\r\n</mv-function>\r\n```\r\n\r\nor without custom elements:\r\n\r\n```html\r\n<div mv-function=\"myDateFormat\">\r\n    <meta property=\"output\" content=\"[month(input)] [ordinal(day(input))], [year(input)]\">\r\n</div>\r\n```\r\n\r\nand then you can call it in other expressions like `[myDateFormat(date)]` (where date is a date property).\r\n\r\nAdditional arguments could be `input2`, `input3` etc. Or we could have named arguments via properties:\r\n\r\n```html\r\n<div mv-function=\"myDateFormat\">\r\n    <meta property=\"date\" />\r\n    <meta property=\"output\" content=\"[month(date)] [ordinal(day(date))], [year(date)]\">\r\n</div>\r\n```\r\n\r\nOR what if every group with an `output` property creates such a function? Then people don't need to learn ANY new syntax! Like this:\r\n\r\n```html\r\n<div property=\"myDateFormat\">\r\n    <meta property=\"date\" />\r\n    <meta property=\"output\" content=\"[month(date)] [ordinal(day(date))], [year(date)]\">\r\n</div>\r\n```\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/mavoweb/mavo/issues/comments/352286260","html_url":"https://github.com/mavoweb/mavo/issues/161#issuecomment-352286260","issue_url":"https://api.github.com/repos/mavoweb/mavo/issues/161","id":352286260,"user":{"login":"LeaVerou","id":175836,"avatar_url":"https://avatars1.githubusercontent.com/u/175836?v=4","gravatar_id":"","url":"https://api.github.com/users/LeaVerou","html_url":"https://github.com/LeaVerou","followers_url":"https://api.github.com/users/LeaVerou/followers","following_url":"https://api.github.com/users/LeaVerou/following{/other_user}","gists_url":"https://api.github.com/users/LeaVerou/gists{/gist_id}","starred_url":"https://api.github.com/users/LeaVerou/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LeaVerou/subscriptions","organizations_url":"https://api.github.com/users/LeaVerou/orgs","repos_url":"https://api.github.com/users/LeaVerou/repos","events_url":"https://api.github.com/users/LeaVerou/events{/privacy}","received_events_url":"https://api.github.com/users/LeaVerou/received_events","type":"User","site_admin":false},"created_at":"2017-12-17T21:17:38Z","updated_at":"2017-12-17T21:17:38Z","author_association":"OWNER","body":"@caraya is making excellent points here. Also, whoever knows JS and wants to use lodash can just include them and then do `$.extend(Mavo.Functions, _)` and done. Similar for the rest.\r\n\r\nPlease keep in mind that this thread is about how Mavo authors (who do not necessarily know JS) can define their own functions and whether this is useful. Can we stay on that topic, please? :) "}}
{"actor":{"display_login":"LeaVerou"}}