{"result":{"depiction_url":null,"edges":{"references":{"objects":[{"created":"2020-05-30T05:48:05Z","object_id":{"id":1844,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_search","title":"search","uri":"https:\/\/zotonic.com\/id\/1844"},"seq":1000000}],"predicate":{"id":332,"is_a":["meta","predicate"],"name":"references","title":{"_type":"trans","tr":{"en":"References"}},"uri":"https:\/\/zotonic.com\/id\/references"}},"refers":{"objects":[{"created":"2026-09-09T13:48:29Z","object_id":{"id":1844,"is_a":["text","documentation","reference","model"],"name":"doc_model_model_search","title":"search","uri":"https:\/\/zotonic.com\/id\/1844"},"seq":1000000}],"predicate":{"id":2409,"is_a":["meta","predicate"],"name":"refers","title":{"_type":"trans","tr":{"en":"Refers"}},"uri":"https:\/\/zotonic.com\/id\/refers"}},"subject":{"objects":[{"created":"2026-09-09T13:48:29Z","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:29Z","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:29Z","object_id":{"id":2620,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_template","title":"Template","uri":"https:\/\/zotonic.com\/id\/2620"},"seq":3},{"created":"2026-09-09T13:48:29Z","object_id":{"id":2641,"is_a":["categorization","keyword","keyword_task"],"name":"zotonic_topic_render","title":"Render","uri":"https:\/\/zotonic.com\/id\/2641"},"seq":4},{"created":"2026-09-09T13:48:29Z","object_id":{"id":2665,"is_a":["categorization","keyword","keyword_data_type"],"name":"zotonic_topic_structured_data","title":"Structured data","uri":"https:\/\/zotonic.com\/id\/2665"},"seq":5}],"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":1383,"is_a":["text","documentation","reference","template_tag"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1383"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_template_tag_tag_with","page_url":{"en":"https:\/\/zotonic.com\/docs\/1383\/with","x-default":"https:\/\/zotonic.com\/docs\/1383\/with"},"preview_url":null,"resource":{"version":3996,"pivot_location_lat":null,"title":"with","is_authoritative":true,"body":"<p>Assign a complex value to a variable.<\/p>\n<p>The <code>{% with %}<\/code> tag assigns the result of a variable expression to a new variable. This is useful when accessing an “expensive” method (e.g., one that hits the database) multiple times. The <code>{% with %}<\/code> tag is often used in conjunction with the search model <a href=\"\/id\/doc_model_model_search\" class=\"doc-reference doc-reference-model\"><code>model#search<\/code><\/a>.<\/p>\n<p>For example:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% with m.search[{latest cat=&quot;news&quot;}] as latest_news %}\n  The latest {% latest_news|length %} news articles:\n  {% for id in latest_news %}\n     {{ m.rsc[id].title }}\n  {% endfor %}\n{% endwith %}\n<\/code><\/pre>\n<p>This outputs the number of latest news articles and also the titles of the news articles. The search is only done once when the <code>{% with %}<\/code> tag assigns the variable “latest_news”.<\/p>\n<h2>Multiple assignments<\/h2>\n<p>It is also possible to assign multiple variables with a single with statement, like this:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">{% with &quot;value1&quot;, &quot;value2&quot; as foo, bar %}\n  {{ foo }}\n  {{ bar }}\n{% endwith %}\n<\/code><\/pre>\n<p>This will output <code>value1 value2<\/code>.<\/p>","slug":"with","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"67b4412c35df8612b7ea4daea75bd66e74323a11d25a40b0e4dfd4dd3e0b27a8","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":324,"is_a":["meta","category"],"name":"template_tag","title":"Tags","uri":"https:\/\/test.zotonic.com\/id\/324"},"doc_source_path":"doc\/template-tags\/with.md","publication_start":"2023-06-24T08:17:52Z","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/doc\/template-tags\/with.md","pivot_location_lng":null,"doc_source_kind":"template_tag","name":"doc_template_tag_tag_with","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2020-05-30T05:47:20Z","uri":null,"doc_status":"current","is_dependent":false,"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":"66cb145eae7002b184e7d8c4c7bba5e53e8248e5\n","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"modified":"2026-10-02T12:40:50Z","title_slug":"with"},"uri":"https:\/\/zotonic.com\/id\/1383","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1383"}},"status":"ok"}