An open API service indexing awesome lists of open source software.

https://github.com/raideno/better-ejs


https://github.com/raideno/better-ejs

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

          

# Better-Ejs:

![](https://img.shields.io/badge/-In%20developement-yellow)
badge

***Not fully ready to use***

## Install:

```
npm install better-ejs
```

## How to use:

**index.js:**

```js
const app = express();
const { engine: bjs } = require('better-ejs');

/*Tell express about better-ejs*/
bjs(app);
/*Set the default express view engine to better-ejs*/
app.set('view engine', 'bjs');

app.get('/:user?', (req, res) => {
const user = req.params.user | 'No One';
res.render('index', { user });
});

app.listen(3000, () => console.log('[Port]:', 3000));
```

**views/index.bjs**

```html

{{ include("./components/navbar.bjs", { user }); }}

Home


User: {{ out(user) }}



{{
if (user === "admin")
{
out("It's an admin !");
}
else out("It's not and admin !");
}}

```

**views/components/navbar.bjs**

```html


NavBar:
{{
if (user) {
out(user)
} else {
out("Login");
}
}}


```

## Documentation

`out(...data:string)`: To output something to the Html Document

## Known Issues

- Remove the access to variables defined in the `compiler/index.ts` file to the user to prevent future problems