{"action":"created","issue":{"url":"https://api.github.com/repos/PebbleTemplates/pebble/issues/407","repository_url":"https://api.github.com/repos/PebbleTemplates/pebble","labels_url":"https://api.github.com/repos/PebbleTemplates/pebble/issues/407/labels{/name}","comments_url":"https://api.github.com/repos/PebbleTemplates/pebble/issues/407/comments","events_url":"https://api.github.com/repos/PebbleTemplates/pebble/issues/407/events","html_url":"https://github.com/PebbleTemplates/pebble/issues/407","id":364381544,"node_id":"MDU6SXNzdWUzNjQzODE1NDQ=","number":407,"title":"Passing the writer instance to sub templates (question)","user":{"login":"danielstieger","id":818898,"node_id":"MDQ6VXNlcjgxODg5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/818898?v=4","gravatar_id":"","url":"https://api.github.com/users/danielstieger","html_url":"https://github.com/danielstieger","followers_url":"https://api.github.com/users/danielstieger/followers","following_url":"https://api.github.com/users/danielstieger/following{/other_user}","gists_url":"https://api.github.com/users/danielstieger/gists{/gist_id}","starred_url":"https://api.github.com/users/danielstieger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielstieger/subscriptions","organizations_url":"https://api.github.com/users/danielstieger/orgs","repos_url":"https://api.github.com/users/danielstieger/repos","events_url":"https://api.github.com/users/danielstieger/events{/privacy}","received_events_url":"https://api.github.com/users/danielstieger/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-27T09:23:17Z","updated_at":"2018-09-27T15:19:36Z","closed_at":"2018-09-27T15:19:36Z","author_association":"NONE","body":"Gentlemen,\r\n\r\ni didn't find a place to post a question, so it ended up as this issue. I beg for excuse if this is the wrong place ... \r\n\r\nI m just wondering how one can/should render sub-templates with pebble. With the django template engine, this is quite straightforward, since strings are return when evaluating a template against a context. In Pebble, the result is rendered to a writer instance. \r\n\r\nIn django i could do\r\n```\r\n{% for delegate in form.delegate %}\r\n{{ delegate.toHtml }}\r\n{% endfor %}\r\n```\r\nEach delegate (and editor) in a form is quite complicated and comes with its own local context map. Since they are so different, only the delegate itself knows variables available in that context. Thus, the toHtml() method just uses a locally, already complied template and puts its rendered content into some outer form template. \r\n\r\nNow of course i could implement the toHtml() method for pebble as \r\n```java\r\nString toHtml() {\r\nStringWriter writer = new StringWriter();\r\n.... context = ;\r\n\r\nprecompiledPebbleTemplate.evalute(writer, context);\r\nreturn writer.toString()\r\n}\r\n```\r\nHowever, i have to instantiate that StringWriter to get some String content back.. \r\n\r\nIs there an more obvious way to handle such a scenario? Or should i pass in the Http Writer to each delegate when instantiating in a form that i do addToWriter() instead of toHtml()\r\n\r\n```java\r\nvoid addToWriter() {\r\n.... context = ;\r\n\r\nprecompiledPebbleTemplate.evalute(global_http_writer_instance, context);\r\n}\r\n```\r\n\r\nOr, alternatively, is there a way to come up with a ` void toHtlm(Writer writer) { ... }`, but then, i would need to pass over the writer somehow ..\r\n\r\n\r\nCheers, any suggestion appreaciated,\r\nDaniel\r\n  \r\n\r\n \r\n\r\n\r\n "},"comment":{"url":"https://api.github.com/repos/PebbleTemplates/pebble/issues/comments/425133370","html_url":"https://github.com/PebbleTemplates/pebble/issues/407#issuecomment-425133370","issue_url":"https://api.github.com/repos/PebbleTemplates/pebble/issues/407","id":425133370,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTEzMzM3MA==","user":{"login":"danielstieger","id":818898,"node_id":"MDQ6VXNlcjgxODg5OA==","avatar_url":"https://avatars3.githubusercontent.com/u/818898?v=4","gravatar_id":"","url":"https://api.github.com/users/danielstieger","html_url":"https://github.com/danielstieger","followers_url":"https://api.github.com/users/danielstieger/followers","following_url":"https://api.github.com/users/danielstieger/following{/other_user}","gists_url":"https://api.github.com/users/danielstieger/gists{/gist_id}","starred_url":"https://api.github.com/users/danielstieger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielstieger/subscriptions","organizations_url":"https://api.github.com/users/danielstieger/orgs","repos_url":"https://api.github.com/users/danielstieger/repos","events_url":"https://api.github.com/users/danielstieger/events{/privacy}","received_events_url":"https://api.github.com/users/danielstieger/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T15:19:36Z","updated_at":"2018-09-27T15:19:36Z","author_association":"NONE","body":"Indeed sir,\r\n\r\nthis is a compelling solution. It s possible to include \"dynamically\" by referencing vars, as well as creating context by vars . Nice, didn t realize that! \r\n\r\nThanks a lot!!! \r\n\r\n"}}
{"actor":{"display_login":"danielstieger"}}