{"action":"opened","issue":{"url":"https://api.github.com/repos/BrightFlair/PHP.Gt/issues/235","labels_url":"https://api.github.com/repos/BrightFlair/PHP.Gt/issues/235/labels{/name}","comments_url":"https://api.github.com/repos/BrightFlair/PHP.Gt/issues/235/comments","events_url":"https://api.github.com/repos/BrightFlair/PHP.Gt/issues/235/events","html_url":"https://github.com/BrightFlair/PHP.Gt/issues/235","id":75902980,"number":235,"title":"Improve nested templates","user":{"login":"g105b","id":358014,"avatar_url":"https://avatars.githubusercontent.com/u/358014?v=3","gravatar_id":"","url":"https://api.github.com/users/g105b","html_url":"https://github.com/g105b","followers_url":"https://api.github.com/users/g105b/followers","following_url":"https://api.github.com/users/g105b/following{/other_user}","gists_url":"https://api.github.com/users/g105b/gists{/gist_id}","starred_url":"https://api.github.com/users/g105b/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/g105b/subscriptions","organizations_url":"https://api.github.com/users/g105b/orgs","repos_url":"https://api.github.com/users/g105b/repos","events_url":"https://api.github.com/users/g105b/events{/privacy}","received_events_url":"https://api.github.com/users/g105b/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/BrightFlair/PHP.Gt/labels/Improvement","name":"Improvement","color":"eb6420"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-05-13T08:38:52Z","updated_at":"2015-05-13T08:38:52Z","closed_at":null,"body":"A nice improvement made in v2 is to be able to insert a templated element back where it originally came from, without having to select its parent in any way. It does this by storing a reference to its parent as it gets extracted from the DOM into the Template object.\r\n\r\nThen when you come to add it back to the page, you can do this:\r\n\r\n```php\r\n$messageItem = $this->template->get(\"message-item\");\r\n$messageItem->insertTemplate();\r\n```\r\n\r\nThe `insert` part was crucial - rather than `append`, it remembers the sibling element too in order to keep its original place.\r\n\r\nBut the question is, where does _(or should)_ the template named \"message-item\" get inserted in the following example:\r\n\r\n```html\r\n<div data-template=\"conversation\">\r\n    <h1>Title</h1>\r\n    <ul class=\"messageList\">\r\n        <li data-template=\"message-item\">\r\n            Message content\r\n        </li>\r\n    </ul>\r\n</div>\r\n```\r\n\r\nOnce the first `conversation` element has been inserted, should inserting `message-item` elements go into the original, or the latest added? If the latter, how do we define this?\r\n\r\n@j4m3s I wonder if you could share your ideas on this?"}}