https://github.com/raideno/better-ejs
https://github.com/raideno/better-ejs
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/raideno/better-ejs
- Owner: raideno
- Created: 2022-02-20T19:13:16.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-03-03T21:12:01.000Z (over 4 years ago)
- Last Synced: 2025-10-20T10:56:01.297Z (8 months ago)
- Language: Svelte
- Size: 406 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Better-Ejs:


***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