> 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
