{"action":"created","issue":{"url":"https://api.github.com/repos/xbmc/xbmc/issues/4876","labels_url":"https://api.github.com/repos/xbmc/xbmc/issues/4876/labels{/name}","comments_url":"https://api.github.com/repos/xbmc/xbmc/issues/4876/comments","events_url":"https://api.github.com/repos/xbmc/xbmc/issues/4876/events","html_url":"https://github.com/xbmc/xbmc/pull/4876","id":35310967,"number":4876,"title":"New feature: Added parameters to skin include directive ($PARAM[Name])","user":{"login":"dslijepcevic","id":1915869,"avatar_url":"https://avatars.githubusercontent.com/u/1915869?v=3","gravatar_id":"","url":"https://api.github.com/users/dslijepcevic","html_url":"https://github.com/dslijepcevic","followers_url":"https://api.github.com/users/dslijepcevic/followers","following_url":"https://api.github.com/users/dslijepcevic/following{/other_user}","gists_url":"https://api.github.com/users/dslijepcevic/gists{/gist_id}","starred_url":"https://api.github.com/users/dslijepcevic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dslijepcevic/subscriptions","organizations_url":"https://api.github.com/users/dslijepcevic/orgs","repos_url":"https://api.github.com/users/dslijepcevic/repos","events_url":"https://api.github.com/users/dslijepcevic/events{/privacy}","received_events_url":"https://api.github.com/users/dslijepcevic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/xbmc/xbmc/labels/API%20change","name":"API change","color":"02d7e1"},{"url":"https://api.github.com/repos/xbmc/xbmc/labels/Feature","name":"Feature","color":"0b02e1"}],"state":"open","locked":false,"assignee":{"login":"Montellese","id":75864,"avatar_url":"https://avatars.githubusercontent.com/u/75864?v=3","gravatar_id":"","url":"https://api.github.com/users/Montellese","html_url":"https://github.com/Montellese","followers_url":"https://api.github.com/users/Montellese/followers","following_url":"https://api.github.com/users/Montellese/following{/other_user}","gists_url":"https://api.github.com/users/Montellese/gists{/gist_id}","starred_url":"https://api.github.com/users/Montellese/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Montellese/subscriptions","organizations_url":"https://api.github.com/users/Montellese/orgs","repos_url":"https://api.github.com/users/Montellese/repos","events_url":"https://api.github.com/users/Montellese/events{/privacy}","received_events_url":"https://api.github.com/users/Montellese/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/xbmc/xbmc/milestones/28","labels_url":"https://api.github.com/repos/xbmc/xbmc/milestones/28/labels","id":396041,"number":28,"title":"Awaiting answer from dev","description":"","creator":{"login":"MartijnKaijser","id":907436,"avatar_url":"https://avatars.githubusercontent.com/u/907436?v=3","gravatar_id":"","url":"https://api.github.com/users/MartijnKaijser","html_url":"https://github.com/MartijnKaijser","followers_url":"https://api.github.com/users/MartijnKaijser/followers","following_url":"https://api.github.com/users/MartijnKaijser/following{/other_user}","gists_url":"https://api.github.com/users/MartijnKaijser/gists{/gist_id}","starred_url":"https://api.github.com/users/MartijnKaijser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MartijnKaijser/subscriptions","organizations_url":"https://api.github.com/users/MartijnKaijser/orgs","repos_url":"https://api.github.com/users/MartijnKaijser/repos","events_url":"https://api.github.com/users/MartijnKaijser/events{/privacy}","received_events_url":"https://api.github.com/users/MartijnKaijser/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":0,"state":"open","created_at":"2013-08-06T19:45:46Z","updated_at":"2015-01-29T18:30:26Z","due_on":null,"closed_at":null},"comments":73,"created_at":"2014-06-09T18:34:58Z","updated_at":"2015-02-20T08:02:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/xbmc/xbmc/pulls/4876","html_url":"https://github.com/xbmc/xbmc/pull/4876","diff_url":"https://github.com/xbmc/xbmc/pull/4876.diff","patch_url":"https://github.com/xbmc/xbmc/pull/4876.patch"},"body":"Skin includes have been enhanced to accept parameters and thus be able to generate dynamic content based on them. Basically, they can now act as \"procedures\" where needed. This can help clean up XMLs a bit, making skins much easier to read and maintain. It also allows for more component-based modular skin design.\r\n\r\nThe syntax is as follows:\r\n\r\n_include definition_:\r\n\r\n```xml\r\n<!-- default parameter values are specified here -->\r\n<include name=\"MyControl1\" p:posx=\"120\" p:posy=\"120\" p:border=\"5\" p:background=\"foo.png\">\r\n  <control ...>\r\n    <posx>$PARAM[posx]</posx>\r\n    <posy>$PARAM[posy]</posy>\r\n    <control ...>\r\n      ...\r\n      <texture border=\"$PARAM[border]\">$PARAM[background]</texture>\r\n    </control>\r\n    ...\r\n    <!-- nested include call -->\r\n    <include p:color=\"$PARAM[color]\">MyControl2</include>\r\n    ...\r\n  </control>\r\n  ...\r\n</include>\r\n```\r\n\r\n_include \"call\"_:\r\n\r\n```xml\r\n  <include file=\"MyControls.xml\" p:posx=\"225\" p:posy=\"150\" p:color=\"white\">MyControl1</include>\r\n```\r\n\r\nRules:\r\n\r\n* Attributes with namespace prefix \"p:\" in include tag denote custom parameters, to differentiate them from built-in ones ('file', 'name', 'condition', etc.)\r\n* Default values for parameters can be specified within *include definition* tag\r\n* Concrete arguments are specified within *include call* tag\r\n* Actual arguments are a combination of these two, with passed arguments having a higher priority over default ones\r\n* Parameter references in the form of $PARAM[ParamName] are replaced with actual arguments within include definition body (inside tag values and attribute values)\r\n* There can be one or more parameter references specified within a single tag/attribute value, possibly in combination with other characters (e.g. p:debug=\"x: $PARAM[x]; y: $PARAM[y]\")\r\n* Parameter references are resolved before everything else ($INFO labels, $LOCALIZE, etc.), so these can be passed as arguments too\r\n* Parameter references that refer to missing/undefined parameters are replaced with empty strings; one exception to this rule is when forwarding a missing parameter of the form p:name=\"$PARAM[MissingParam]\" from enclosing include to the nested include, where this parameter, which would normally be expanded to \"\", won't be passed at all, allowing any default value from the nested include to be correctly picked up and not overriden by \"\"\r\n* Extra parameters in include call that are passed but not referenced anywhere within include definition are ignored\r\n* Incomplete parameter references (without closing ']') are logged as errors and left as is, rather than resolved to empty strings\r\n\r\nThis feature was proposed and discussed in more detail here: http://forum.xbmc.org/showthread.php?tid=190135. It requires a change in Wiki documentation which I can help with if it gets accepted."},"comment":{"url":"https://api.github.com/repos/xbmc/xbmc/issues/comments/75202403","html_url":"https://github.com/xbmc/xbmc/pull/4876#issuecomment-75202403","issue_url":"https://api.github.com/repos/xbmc/xbmc/issues/4876","id":75202403,"user":{"login":"Montellese","id":75864,"avatar_url":"https://avatars.githubusercontent.com/u/75864?v=3","gravatar_id":"","url":"https://api.github.com/users/Montellese","html_url":"https://github.com/Montellese","followers_url":"https://api.github.com/users/Montellese/followers","following_url":"https://api.github.com/users/Montellese/following{/other_user}","gists_url":"https://api.github.com/users/Montellese/gists{/gist_id}","starred_url":"https://api.github.com/users/Montellese/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Montellese/subscriptions","organizations_url":"https://api.github.com/users/Montellese/orgs","repos_url":"https://api.github.com/users/Montellese/repos","events_url":"https://api.github.com/users/Montellese/events{/privacy}","received_events_url":"https://api.github.com/users/Montellese/received_events","type":"User","site_admin":false},"created_at":"2015-02-20T08:02:04Z","updated_at":"2015-02-20T08:02:04Z","body":"@xhaggi: I agree that we should not support multiple ways to achive the same goal because suddenly you have to handle cases where the skinner uses attributes and child-elements and it's non-obvious which one takes precedence.\r\n\r\nI guess we agree on having to use attributes for defining the parameters in the include definition.\r\nFor the include statement itself, taking your example from above either one looks fine to me:\r\n* **Attributes**\r\n```xml\r\n<include name=\"MyInclude\"\r\n  p:x=\"value1\"\r\n  p:y=\"value2\"\r\n  p:z=\"$PARAM[k]\"\r\n  p:q=\"20\" />\r\n```\r\n* **Child-elements**\r\n```xml\r\n<include name=\"MyInclude\" forwardparams=\"true|false\">\r\n  <param name=\"x\" value=\"value1\" />\r\n  <param name=\"y\" value=\"value2\" />\r\n  <param name=\"z\">$PARAM[k]</param>\r\n  <param name=\"q\">20</param>\r\n</include>\r\n```\r\nIf we go for child elements we should probably just support passing the value either in the content of the `<param>`  tag or as a value of the `value` attribute but not a mix (as in the example above)."}}