{"result":{"depiction_url":null,"edges":{"in_module":{"objects":[{"created":"2026-09-09T13:48:08Z","object_id":{"id":335,"is_a":["text","documentation","reference","module"],"name":"doc_core","title":"Zotonic Core","uri":"https:\/\/zotonic.com\/id\/335"},"seq":1}],"predicate":{"id":333,"is_a":["meta","predicate"],"name":"in_module","title":{"_type":"trans","tr":{"en":"In module"}},"uri":"https:\/\/zotonic.com\/id\/in_module"}},"subject":{"objects":[{"created":"2026-09-09T13:48:08Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2564,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_backend_developer","title":"Backend developer","uri":"https:\/\/zotonic.com\/id\/2564"},"seq":3},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2620,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_template","title":"Template","uri":"https:\/\/zotonic.com\/id\/2620"},"seq":4},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2625,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_model","title":"Model","uri":"https:\/\/zotonic.com\/id\/2625"},"seq":5},{"created":"2026-09-09T13:48:08Z","object_id":{"id":2641,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_render","title":"Render","uri":"https:\/\/zotonic.com\/id\/2641"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":1339,"is_a":["text","documentation","reference","model"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1339"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_model_model_template","page_url":{"en":"https:\/\/zotonic.com\/docs\/1339\/template","x-default":"https:\/\/zotonic.com\/docs\/1339\/template"},"preview_url":null,"resource":{"version":4100,"pivot_location_lat":null,"title":"template","is_authoritative":true,"body":"<p>Model for dynamic template rendering. It renders a template path passed in the request path and returns the rendered template output.<\/p>\n<h2>Available Model API Paths<\/h2>\n<table class=\"table\"><thead><tr><th>Method<\/th><th>Path pattern<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td><code>get<\/code><\/td><td><code>\/render_with_assets\/...<\/code><\/td><td>Return a map with <code>html<\/code>, <code>libs<\/code> and <code>javascript<\/code>. Pass it to <code>z_assets.apply(result, insertHtml)<\/code> in the browser; the insertion callback runs after libraries load and before initialization.<\/td><\/tr><tr><td><code>get<\/code><\/td><td><code>\/render\/...<\/code><\/td><td>Treat segments after <code>\/render\/<\/code> as the template path, render that template with the payload query args, and return the rendered template output.<\/td><\/tr><\/tbody><\/table>\n<p>Both paths expose payload values as <code>q<\/code>, with the caller&#39;s normal ACL context.\nThe asset-aware path requires the standard Cotonic head and wired JavaScript\nincludes and <code>{% script %}<\/code>. For example:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-javascript\">cotonic.broker.call(\n    &#39;bridge\/origin\/model\/template\/get\/render_with_assets\/_panel.tpl&#39;,\n    { id: 123 }\n).then(response =&gt; z_assets.apply(response.payload.result, html =&gt; {\n    document.getElementById(&#39;panel&#39;).innerHTML = html;\n}));\n<\/code><\/pre>\n<p>The insertion callback may return a promise. Libraries finish loading before it\nruns; collected template JavaScript runs after it completes. Failed library\nloads skip the update. CSS variants are distinguished by media, rel and title;\nJavaScript executes once per page, in declaration order. Dynamic updates wait\nfor their dependencies even when the original lib tag specifies async\/defer.\nThe HTML-only path remains available, but materialized HTML cannot subsequently\nbe deduplicated against other fragments. Prefer the asset-aware path for updates.<\/p>\n<p><code>\/+name<\/code> marks a variable path segment. A trailing <code>\/...<\/code> means extra path segments are accepted for further lookups.<\/p>","slug":"template","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"47ba9dcd70c1d9a02020ea1ed27437cbca124a7a5fa1ec9ef5d0ed2ecdfafcc0","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":322,"is_a":["meta","category"],"name":"model","title":"Models","uri":"https:\/\/test.zotonic.com\/id\/322"},"doc_source_path":"apps\/zotonic_core\/src\/models\/m_template.erl","publication_start":"2023-06-24T08:17:50Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/apps\/zotonic_core\/src\/models\/m_template.erl","pivot_location_lng":null,"doc_source_kind":"model","name":"doc_model_model_template","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2020-05-30T05:47:19Z","uri":null,"doc_status":"current","is_dependent":false,"erlang_app":"zotonic_core","publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"ec47cc8e0b6c699c8c091fce132f80a6f55b753a\n","erlang_module":"m_template","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-10-26T22:00:51Z","title_slug":"template"},"uri":"https:\/\/zotonic.com\/id\/1339","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1339"}},"status":"ok"}