# Coding Standars

When crafting templates, it's recommended to adhere to the official coding standards outlined below:

* Use a single space after the beginning of a delimiter (`{{`, `{%`, and `{#`) and before the end of a delimiter (`}}`, `%}`, and `#`):

  ```twig
  {{ foo }}
  {# comment #}
  {% if foo %}{% endif %}
  ```
* With the whitespace control character, avoid any spaces between it and the delimiter:

  ```twig
  {{- foo -}}
  {#- comment -#}
  {%- if foo -%}{%- endif -%}
  ```
* Maintain one space before and after these operators: comparison (`==`, `!=`, `<`, `>`, `>=`, `<=`), math (`+`, `-`, `/`, `*`, `%`, `//`, `**`), logic (`not`, `and`, `or`), `~`, `is`, `in`, and ternary (`?:`):

  ```twig
  {{ 1 + 2 }}
  {{ foo ~ bar }}
  {{ true ? true : false }}
  ```
* Insert a single space after the `:` in hashes and `,` in arrays and hashes:

  ```twig
  {{ [1, 2, 3] }}
  {{ {'foo': 'bar'} }}
  ```
* Refrain from adding spaces after an opening parenthesis or before a closing parenthesis:

  ```twig
  {{ 1 + (2 * 3) }}
  ```
* Ensure no spaces exist before and after string delimiters:

  ```twig
  {{ 'foo' }}
  {{ "foo" }}
  ```
* Avoid spaces before and after these operators: `|`, `.`, `..`, `[]`:

  ```twig
  {{ foo|upper|lower }}
  {{ user.name }}
  {{ user[name] }}
  {% for i in 1..12 %}{% endfor %}
  ```
* Don't add spaces before and after the parenthesis for filter and function calls:

  ```twig
  {{ foo|default('foo') }}
  {{ range(1..10) }}
  ```
* For arrays and hashes, no spaces should exist after the opening and before the closing:

  ```twig
  {{ [1, 2, 3] }}
  {{ {'foo': 'bar'} }}
  ```
* Use lowercase and underscore for variable names:

  ```twig
  {% set foo = 'foo' %}
  {% set foo_bar = 'foo' %}
  ```
* Maintain consistent indentation inside tags.

  ```twig
  {% block foo %}
      {% if true %}
          true
      {% endif %}
  {% endblock %}
  ```


---

# 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://docs.promptcake.com/form-builder/templates/coding-standars.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.
