Introducing Rino: New Web Framework
Tags: webdev, javascript, opensource, tutorial
Published: 2023-09-13 03:55:46


![Rino Logo](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r7sp96edp9cned6zrlev.png)

Originally created as a templating tool for Content Management Systems, Rino has evolved into a powerful web development framework. In this post, we'll explore Rino and its unique features.

## Rino vs. Vue and React
Is Rino better than Vue and React? Well, it's not about being better; it's about being different. While Vue and React are primarily used for building a web application, Rino focuses on building web pages and support Server-Side Rendering (SSR) and Static Site Generation (SSG) like Next (React) and Nuxt (Vue).

## Installation
Getting started with Rino is easy. You can set up your project manually, but we've also prepared a project starter to streamline the process:

```
npm create rino@latest
```


![Rino install](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qlf3vejsxchuz4xavyb9.PNG)

Once your project is set up, you can start development with the following command:
```
npm run dev
```

![Rino default page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6iyv7v3gdoyj3foh2gya.PNG)
## Understanding the Rino System

Rino divides the entire development process into two key parts: preprocessing and client-side rendering. Preprocessing involves the Rino core building a web page from preprocessing syntax. You can also incorporate Rinokit or any other front-end libraries for client-side rendering. In a Rino page, anything that's preprocessed begins with the `@` symbol, such as `{{ @component, ./src/components/component-name.tot }}`.

One unique aspect of Rino is its reliance on the .tot file format. Originally designed as an attempt to create a JavaScript database, it evolved into a data management file format. Rino leverages the .tot format because of its simplicity, linearity, and readability. Additionally, you can use .tot files for data storage, and even internationalization (i18n) can be achieved with them.

```
<d:html>
</d:html>
<d:js>
</d:js>
<d:css>
</d:css>
<d:somd-data>
</d:somd-data>
```
## Generating a component with Javascript
First, introducing a new feature that has been added recently. This is a feature to create components with Javascript. And the recently created document tool Rino Docs uses this to create sidebar elements. You can create various things using ‘result’, ‘data’ and ‘props’.

```
{{(
    result = `<ul class="menu-list">`
    let list = data.pageList;

    for(let i = 0; i < list.length; i++)
    {
        if(i == 0)
        {
            result = result + `
                <li><a href="/">${ list[i] }</a></li>
            `;
        }
        else
        {
            result = result + `
                <li><a href="/${ list[i] }.html">${ list[i] }</a></li>
            `;
        }
    }

    result = result + `</ul>`
)}}
```

![Rino Docs Image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ajjca7yhkxgx89i0t1a8.PNG)

## Editing a page
Editing a Rino page is straightforward. For example, here's how you can structure an index.tot page.

./src/pages/index.tot:
```
<d:html>
<!DOCTYPE html>
<html>
    <head>
        <script type="text/javascript" src="main.js"></script>
        <link rel="stylesheet" href="style.css">

        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>{{ @data.title }}</title>
    </head>
    <body>
        Some content..
    </body>
</html>
</d:html>
<d:js>
</d:js>
<d:css>
</d:css>
```

If you're familiar with Vue, you'll find it relatively easy to understand Rino's structure. HTML goes inside `<d:html></d:html>`, JavaScript inside `<d:js></d:js>`, and CSS inside `<d:css></d:css>`. These components will be built into respective HTML, JS, and CSS files.

## Markdown and Tot Support
Rino offers native support for Markdown and .tot files. You can include them in your pages as follows:

```
<d:html>
some html content...
{{ @md, ./src/mds/somecontent.md }}
some html content...
</d:html>
```
```
<d:html>
some html content...
{{ @tot.tagname, ./src/tots/somedata.tot }}
some html content...
</d:html>
```

## Component support
Rino simplifies component integration. To include a component, follow these steps:

1. Use the @component
2. Specify the file path to the component
3. Add props (We are not going to use props in the example.)

./src/components/sometest.tot:
```
<d:html>
some html...
{{ @component, ./src/components/some-component.tot }}
some html...
</d:html>
```
./src/components/some-component.tot:
```
<d:html>
<div>
some component
</div>
</d:html>
```
Result:
```
some html...
<div>
some component
</div>
some html...
```


## Adding a New Page

Adding a new page in Rino is straightforward. You can modify index.js and pass a list of pages, or in the default setting, you can add another page from pages.js. Here's how you can do it.

./src/pages.js:
```
const path = require('path');

async function pages()
{
    return [
        {
            data: {
                title: "Rino.js",
                desc: "Fast learning, preprocessing, intuitive web framework. Rino.js",
                url: ""
            },
            pageFilename: path.resolve(__dirname, "./pages/index.tot"),
            distDirname: path.resolve(__dirname, "../dist/"),
            filenames: {
                css: "style.css",
                js: "main.js"
            }
        },
        {
            Another page information
        }
    ]
}
// Make sure filenames are diffrent between pages.
// Because exported HTML, Javascript and CSS are should be totally different. For making files more light.
module.exports = { pages }
```

## For the last

Rino offers an interesting approach to web development. Its simplicity and support for .tot files make it a unique addition to the web development toolkit. Give it a try and see how it fits into your next project!

## Useful Links 🌐
- [Official Rino Website](https://rinojs.org/)
- [Rino Github](https://github.com/rinojs)