> For the complete documentation index, see [llms.txt](https://docs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akinon.com/technical-guides/project-zero/django/page-types/account-page/template-rendering-in-account-pages.md).

# Template Rendering in Account Pages

Majority of account pages are rendered using only Jinja and intervened with JS if necessary after the page is launched. Some pages, however, are first rendered with Jinja and then the template in question is once again rendered with JS during later updates. These pages are:

* Address (/account/address)
* Favourites (/account/favourite-products/)

## <mark style="color:red;">Default Templates​</mark> <a href="#default-templates" id="default-templates"></a>

As in other pages that use a combination of Jinja and JS render methods, the Address and Favourites pages contain files titled `default_templates.html`. These files include "default template", which is to be rendered with JS.

```
<a class="d-block" href="%\_url\_%">
  %\_img\_%
</a>
```

The `%_url_%` and `%_img_%` fields in this example are rendered with RegExp match on JS and sent to the page to be rendered again. The function that carries out this action is as follows:

```
export const templateRenderer = (templateHtml, data) => {
  let result = templateHtml;

  for (const key in data) {
    result = result.replace(new RegExp(`%\_${key}\_%`, 'g'), data[key]);
  }

  return result;
};

// Usage
const favouriteProduct = templateRenderer($('#FavoriteProductItem').html(), data);
```

In the above example;

1. the parameter `templateHtml` should refer to the entire template (HTML) to fill in. For instance, the `.html()` method can be used with jQuery.
2. the parameter `data` should be an object and the `key`s of this object should match the `%_key_%` fields in the template. Therefore, the matching `value` of `key` is inserted in the relevant field in the template and is rendered.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.akinon.com/technical-guides/project-zero/django/page-types/account-page/template-rendering-in-account-pages.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
