Socket
Socket
Sign inDemoInstall

wjst

Package Overview
Dependencies
20
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    wjst

A simple, powerful, and extendable templating engine for node.js and browsers, similar to Django, Jinja2, and Twig.


Version published
Weekly downloads
0
Maintainers
1
Created
Weekly downloads
 

Readme

Source

wjst

Wjst is an awesome, Django/Jinja-like template engine for node.js.

Features

  • Available for node.js and major web browsers!
  • Express compatible.
  • Object-Oriented template inheritance.
  • Apply filters and transformations to output in your templates.
  • Automatically escapes all output for safe HTML rendering.
  • Lots of iteration and conditionals supported.
  • Robust without the bloat.
  • Extendable and customizable. See Wjst-Extras for some examples.
  • Great code coverage.

Need Help? Have Questions? Comments?

Installation

npm install wjst

Documentation

All documentation can be viewed online on the Wjst Website.

Basic Example

Template code index.html

<h1>{{ pagename|title }}</h1>
<ul>
{% for author in authors %}
    <li{% if loop.first %} class="first"{% endif %}>{{ author }}</li>
{% endfor %}
</ul>

node.js code

const wjst  = require('wjst');
const template = wjst.compileFile('./index.html');
const output = template({
    pagename: 'awesome people',
    authors: ['Den', 'Paul', 'Jane']
});

Output

<h1>Awesome People</h1>
<ul>
    <li class="first">Den</li>
    <li>Paul</li>
    <li>Jane</li>
</ul>

For working example see examples/basic

How it works

Wjst reads template files and translates them into cached javascript functions. When we later render a template we call the evaluated function, passing a context object as an argument.

Keywords

FAQs

Last updated on 30 Sep 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