Socket
Socket
Sign inDemoInstall

better-ejs

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    better-ejs

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


Version published
Maintainers
1
Created

Readme

Source

Better-Ejs:

badge

Not fully ready to use

Install:

npm install better-ejs

How to use:

index.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

<body>
  {{ include("./components/navbar.bjs", { user }); }}
  <h1>Home<h1>
  <h2>User: <a href="#">{{ out(user) }}</a></h2>
  <h3>
  {{
    if (user === "admin")
    {
      out("It's an admin !");
    }
    else out("It's not and admin !");
  }}
  <h3>
</body>

views/components/navbar.bjs

<nav>
  <h1>
    NavBar: 
    {{
      if (user) {
        out(user)     
      } else {
        out("<a href='/login'>Login</a>");
      }
    }}
  </h1>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/contacts">Contacts</a></li>
    <li><a href="/about">About</a></li>
  </ul>
</nav>

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

Keywords

FAQs

Last updated on 24 Feb 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc