This site is built with Viewi itself. It is experimental and still in development. If you see any bugs please do not hesitate and open an issue or DM me on Twitter.

Template Syntax


To render the component's variable in your template you can use this:


Or you can use the shorthand syntax:


Also you can use the single mustache syntax, the result will be the same:


Please note: all values are automatically encoded (rendered as plain text).

Please note: if you need to output $ or { without triggering interpolation you can escape these with backslash: \$ and \{


To output raw HTML use a double mustache syntax, like this:


Rendering HTML on your website can be very dangerous due to XSS vulnerabilities. Use it only on trusted content.


You can render method's result or even a single line expression:


Please note: single line expression means no code blocks with ;, { ... } or variable assignments. You can use ternary expression if you need:

<div>{ $valid ? 'OK': 'Error' }</div>


Rendering attribute values could not be easier,the syntax is all the same:

<a href="$href" class="red $myClass">My Link</a>
<a href="{getLatestUrl()}">Latest</a>

Nullable Attributes

Attribute will be rendered only if the value is not null:

<div id="$id">Content</div>

$id = null:

$id = 'my-id':
<div id="my-id">Content</div>

Dynamic Attributes

Dynamic attributes ? here you go:

<div $attributeName="my-value">...

Boolean Attributes

If the HTML attribute is boolean you can bypass a condition into an attribute value, and it will render the attribute based on that condition. List of boolean attributes: async autofocus autoplay checked controls default defer disabled formnovalidate hidden ismap itemscope loop multiple muted nomodule novalidate open readonly required reversed selected

<button disabled="$isDisabled">Send</button>
$isDisabled = true: <button disabled="disabled">Send</button>
$isDisabled = false: <button>Send</button>

Conditional Attributes

Conditional attributes help you to simplify using the attributes based on conditions. For example, instead of using $condition ? 'one' : 'two' like here:

<div class="panel {$selected ? 'show' : ''}"></div>

you can use"$selected" like here:

<div class="panel""$selected"></div>

You can have as many attributes as you want, all of them will be merged during the render.

Template Tag

template tag allows you to combine the content into one logical entity. It is a virtual tag and only its content will be rendered. It is useful for grouping and combinations with if or foreach

<template if="$user !== null">

With user { $Name = 'Mike' } will result to:


Dynamic Tag

It happens that at some point you don't know what tag it will be during the application`s life. Therefore you are free to use a dynamic tag, like this:

<$tagName>Some content</$tagName>