jensjeflensje / websk

Create websites using Skript!
MIT License
9 stars 4 forks source link

New Template System Docs - WIP #55

Open Norbiros opened 2 years ago

Norbiros commented 2 years ago

WebSK Template System

Our template system is based on Django's. See https://docs.djangoproject.com/en/4.0/ref/templates/language/ for more info.

Basics

All template tags start with {{ and end with }}. Some tags (for example show) are single, you use them like: {{<tag>}} But others need opening and closing tag (for example loop): {{<tag>}} ... {{/<tag>}}

Ending blocks

To close non single block you can use:

Blocks

Show Block

You can show variable/expression/list etc. {{show random integer between 1 and 5 }} {{show {_websk} }} {{show {@name} }}

HTML is escaped by default (we want to protect users from XSS), but if you want to show HTML, use: {{show unescaped {_html}}}

By default newlines (%nl%) are replaced with <br>, but you can disable that feature in config.

Loop Block

Loop blocks work like loop statement in Skript. To show loop entity, just add {{show loop-entity}}

{{loop intenegers between 1 and 5 }}
  {{show loop-entity}}
{{/loop}}

Comment Block

Context of this block is excluded from result html. {{# <text>}}

Execute Block

This block executes specific skript expression on server.

Condition Block (else, if, elseif)