# utils

O `utils` é um objeto de utilidade técnica que verifica o ambiente da loja virtual, além de adicionar um hash ao final dos assets para que os arquivos não sejam carregados através do cache do navegador.

{% hint style="info" %}
**Disponível em todas as páginas.**
{% endhint %}

### Atributos disponíveis​ <a href="#atributos-disponiveis" id="atributos-disponiveis"></a>

| Atributos                    | Caracteristica                               |
| ---------------------------- | -------------------------------------------- |
| `{{ utils.assets_version }}` | Hash para arquivos estáticos devido a cache. |
| `{{ utils.is_https }}`       | Verifica se está em ambiente seguro.         |
| `{{ utils.is_mobile }}`      | Verifica se o usuário está em um smartphone. |

## Como Usar

Geralmente esse objeto será utilizado em uma condicional `if` ou em algum `href` de tag `link` que for necessário.

### Para aprimorar o carregamento devido ao cache

O objeto `utils` pode ser utilizado como meio de driblar o cache da loja utilizando como no código HTML abaixo.

{% code title="Input" %}

```html
<link href="my.css?{{ utils.assets_version }}" rel="stylesheet"/>
```

{% endcode %}

{% code title="Output" %}

```html
<link href="my.css?123456" rel="stylesheet">
```

{% endcode %}

### Para verificar o ambiente atual

Também é possível verificar se o usuário está em um ambiente seguro "**HTTPS**" utilizando-o como no código HTML abaixo.

{% code title="Input" %}

```html
{% if utils.is_https %}
  <h3>Fique tranquilo, você está navegando em um ambiente seguro!</h3>
{% endif %}
```

{% endcode %}

{% code title="Output" %}

```html
<h3>Fique tranquilo, você está navegando em um ambiente seguro!</h3>
```

{% endcode %}

### Para verificar se o dispositivo atual é Móvel

E verificar se o dispositivo do usuário é um dispositivo móvel "celular, tablet, etc", utilizando-o em condicionais, como o código HTML abaixo, para poder exibir ou ocultar determinados elementos que desejar.

{% code title="Input" %}

```html
{% if utils.is_mobile %}
  </h4>Você está navegando em um smartphone</h4>
{% endif %}
```

{% endcode %}

{% code title="Output" %}

```html
</h4>Você está navegando em um smartphone</h4>
```

{% endcode %}


---

# Agent Instructions: 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:

```
GET https://partners.tray.com.br/themes/construindo-seu-template/referencias/objetos/utils.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
