{"action":"created","issue":{"url":"https://api.github.com/repos/Level-2/Transphporm/issues/131","repository_url":"https://api.github.com/repos/Level-2/Transphporm","labels_url":"https://api.github.com/repos/Level-2/Transphporm/issues/131/labels{/name}","comments_url":"https://api.github.com/repos/Level-2/Transphporm/issues/131/comments","events_url":"https://api.github.com/repos/Level-2/Transphporm/issues/131/events","html_url":"https://github.com/Level-2/Transphporm/issues/131","id":181576556,"number":131,"title":"Best practice for shared templates","user":{"login":"cxj","id":446131,"avatar_url":"https://avatars.githubusercontent.com/u/446131?v=3","gravatar_id":"","url":"https://api.github.com/users/cxj","html_url":"https://github.com/cxj","followers_url":"https://api.github.com/users/cxj/followers","following_url":"https://api.github.com/users/cxj/following{/other_user}","gists_url":"https://api.github.com/users/cxj/gists{/gist_id}","starred_url":"https://api.github.com/users/cxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cxj/subscriptions","organizations_url":"https://api.github.com/users/cxj/orgs","repos_url":"https://api.github.com/users/cxj/repos","events_url":"https://api.github.com/users/cxj/events{/privacy}","received_events_url":"https://api.github.com/users/cxj/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-10-07T03:13:24Z","updated_at":"2016-10-27T12:15:08Z","closed_at":null,"body":"This issue is to ask for some feedback on preferred or intended methods for sharing templates between multiple web sites.\r\n\r\nI have 3 web applications which share View* (in Model-View-Controller terminology) classes which use Transphporm for generating web page output.  They also share a bunch of general purpose templates, e.g. for login, base HTML, etc.  There are then also templates which are unique to each application.\r\n\r\nMy directory structure is something like:\r\n```\r\n./path/to/shared/templates\r\n./path/to/local/templates\r\n```\r\nThat is, the 2 groups of templates are in their own directories with different paths.\r\n\r\nMy View class has no trouble finding the templates it needs.  The difficulty comes in when, for example, I want to use all shared templates and TSS files for a given page _except_ have a custom navigation menu bar at the top.  The navigation pieces are in a local unique template.\r\n\r\nI'd like to find a way to avoid hard-coding into my generic, shared templates the unique path to the local template.  That is, I do _not_ want to do this in `shared.tss` for example:\r\n```css\r\nbody nav {\r\n    content: template(\"/some/path/to/local/templates/navigation.xml\");\r\n}\r\n```\r\nOr:\r\n```css\r\nbody nav {\r\n    content: template(\"../../../../templates/navigation.xml\");\r\n}\r\n```\r\n\r\nBoth of the above _will_ work correctly, but as one might imagine, are very fragile and hard to maintain.\r\n\r\nWhat's a proper way to approach this problem?  \r\n\r\nIdea:  Is there some way to set a base directory for `content: template(...)` and `@import \"...\"` paths, so that all references could be from a known starting point provided from outside the template files themselves?  If not, would that be a sensible feature to add?  I'm thinking something like this:\r\n```php\r\n$tpl = new Transphporm\\Builder($xmlFile, $tssFile);\r\n$tpl->setBasePath($path);                        // suggested new feature\r\nreturn $tpl->output($data)->body;\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/Level-2/Transphporm/issues/comments/256624436","html_url":"https://github.com/Level-2/Transphporm/issues/131#issuecomment-256624436","issue_url":"https://api.github.com/repos/Level-2/Transphporm/issues/131","id":256624436,"user":{"login":"TomBZombie","id":2454540,"avatar_url":"https://avatars.githubusercontent.com/u/2454540?v=3","gravatar_id":"","url":"https://api.github.com/users/TomBZombie","html_url":"https://github.com/TomBZombie","followers_url":"https://api.github.com/users/TomBZombie/followers","following_url":"https://api.github.com/users/TomBZombie/following{/other_user}","gists_url":"https://api.github.com/users/TomBZombie/gists{/gist_id}","starred_url":"https://api.github.com/users/TomBZombie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomBZombie/subscriptions","organizations_url":"https://api.github.com/users/TomBZombie/orgs","repos_url":"https://api.github.com/users/TomBZombie/repos","events_url":"https://api.github.com/users/TomBZombie/events{/privacy}","received_events_url":"https://api.github.com/users/TomBZombie/received_events","type":"User","site_admin":false},"created_at":"2016-10-27T12:15:08Z","updated_at":"2016-10-27T12:15:08Z","body":"I think the only sane way to handle it is to make `/` getcwd() and anything else relative to where the base PHP script is stored. I think anything else would be confusing, unless we want to allow setting the base dir like HTML's `<base>` tag"}}
{"actor":{"display_login":"TomBZombie"}}