Syntax
======

The main element of Neutral TS is the BIF (Build-in function), would be the equivalent of functions and would display an output, the output is always a string or nothing (empty string).

### Bif layout

```plaintext

 .-- open bif
 |     .-- bif name
 |     |               .-- params
 |     |               |             .-- code
 |     |               |             |   .-- close bif
 |     |               |             |   |
 v     v               v             v   v
 -- ------- --------------------  ------ --
 {:!include; {:flg; ... :} file >>  ...  :}
   -       - -------------      --
   ^       ^      ^             ^
   |       |      |             |
   |       |      |             ·-- params/code separator
   |       |      ·-- flags
   |       ·-- name separator
   ·-- modifier

                         .-- source
                         |
                         v
             ----------------------------
 {:!include; {:flg; ... :} file >>  ...  :}
 ------------------------------------------
                     ^
                     |
                     ·-- Bif (Build-in function)

```

Bif example:

```plaintext
{:filled; varname >>
    Hello!
:}
```

Sometimes they only carry parameters or code:

```plaintext
{:snippet; snipname :}
```

Any number of spaces can be used to separate each part of a bif except the name, the following is an error:

```diff
-{: filled ; varname >>
    Hello!
:}

+{:filled; varname >>
    Hello!
:}
```

Any other is valid:

```plaintext
{:filled;varname>>Hello!:}

{:filled;

    varname

    >>

    Hello!

:}

{:filled; varname >>
    Hello!
:}
```

Variables
---------

Variables are defined in the `schema` in the `data` key or in separate files that are loaded with `{:data; ... :}`

```plaintext
{
    "config": {},
    "inherit": {
        "locale": {
            "current": "en",
            "trans": {}
        }
    },
    "data": {
        "site_name": "MySite",
        "site": {
            "name": "MySite"
        }
    }
}
```

Then all we have to do is `{:;varname:}`:

```plaintext
{:;site_name:}
```

Output:

```plaintext
MySite
```

Arrays with the "->" operator

```plaintext
{:;site->name:}
```

Output:

```plaintext
MySite
```

Nesting
-------

By design all Bifs can be nested and there can be a Bif anywhere in another Bif except in the name.

```plaintext
{:eval; {:code; {:code; ... :} :} >>
    {:code;
        {:code;
            ...
        :}
    :}
:}
```

Grouping
--------

```plaintext
{:coalesce;
    {:code; {:* block 1 *:}
        {:code; ... :}
        {:code; ... :}
        {:code; ... :}
    :}
    {:code; {:* block 2 *:}
        {:code; ... :}
    :}
:}
```

Wrapping
--------

Note the following example:

```plaintext
<li>{:snippet; snippet-name :}</li>
```

The output of the above if "snippet-name" is empty will be:

```plaintext
<li></li>
```

To prevent this from happening, it can be done:

```plaintext
{:eval; {:snippet; snippet-name :} >>
    <li>{:;__eval__:}</li>
:}
```

Control flow
------------

The following would be a form of flow control:

```plaintext
{:filled; varname >>
    {:snippet; snipname :}
:}
```
Another:

```plaintext
{:snippet; foo >>
    ...
:}

{:snippet; bar >>
    ...
:}

{:same; /{:;varname:}/foo/ >>
    {:snippet; foo :}
:}

{:same; /{:;varname:}/bar/ >>
    {:snippet; var :}
:}
```

This is clearer and less computationally expensive:

```plaintext
{:snippet; option-foo >>
    ...
:}

{:snippet; option-bar >>
    ...
:}

{:snippet; option-{:;varname:} :}
```

Calling a snippet that does not exist is not an error, it will result in a empty string that we can evaluate with `else`.

```plaintext
{:snippet; option-{:;varname:} :}
{:else: {:snippet; option-default :} :}

```

---
