Syntax
======

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

### BIF Structure

```text

 .-- 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 (Built-in function)

```

BIF example:

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

Sometimes they only carry parameters or code:

```text
{: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:

```text
{: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; ... :}`

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

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

```text
{:;site_name:}
```

Output:

```text
MySite
```

Arrays with the "->" operator

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

Output:

```text
MySite
```

Arguments
---------

Some bifs take arguments, any character can be used as a delimiter:

```text
{:join; /array/separator/ :}
{:join; ~array~separator~ :}
{:join; #array#separator# :}
{:join; |array|separator| :}
{:join; XarrayXseparatorX :}
```

Spaces are taken into account:

```text
{:join; /array/ / :}
{:join; /array/ - / :}
```

They can be nested, but different delimiters must be used:

```text
{:sum; /1/{:sum; |2|2| :}/ :}
```

Nesting
-------

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

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

Grouping
--------

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

Wrapping
--------

Note the following example:

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

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

```text
<li></li>
```

To prevent this from happening, it can be done:

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

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

The following would be a form of flow control:

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

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

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

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

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

This is clearer and less computationally expensive:

```text
{: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`.

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

```

---
