Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jspl

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jspl

JSP-Like (JSPL) is a simple template based on underscore. Compliant with Express. Add the tag include for HTML fragment.

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

jspl

JSP Like Template Engine for ExpressJS and NodeJS (based on underscore, support include, cache...)

Features

  • Cache
  • Include HTML fragment
  • Variables
  • Loop

see: Gists section

Getting started

  1. Install JSPL $npm install jspl -save

  2. Enable JSPL in Express 4


var app = express();

// Disable jade by removing or commenting
//app.set('view engine', 'jade');

// view engine setup

app.set('views', path.join(__dirname, 'views'));

// Enable 

app.set('view cache', false);

// Bind JSPL to express

var jspl = require('jspl');
jspl.bind(app);```


Sample
====

An example of application is available under: sample/express/
it demonstrate the integration of this simple template engine with express.

Gists
---
Add variable
---
File: views/index.html 

Hello <%= name %>

```

File: app.js

app.get('/', function(req, res)
{
  res.render('index', {name: 'John'});
})

Result:

<h1>Hello John</h1>

For loop

File: views/index.html

<h1>Hello</h1>
<ol>
  <% _.each(people, function(name) { %>
   
   <li><%= name %></li>
   
  <% }); %>
</ol>

File: app.js

app.get('/', function(req, res)
{
  res.render('index', {people: ['moe', 'curly', 'larry']});
})

Result:

<h1>Hello</h1>
<ol>
  <li>moe</li>
  <li>curly</li>
  <li>larry</li>
</ol>

Include fragment

Include a HTML page into the current one. <%@ include file="viewName" %>

  • viewName : Location of the included view without extension. The extension .html will be added automatically.
  • <%@ %> : Indicate a tag
  • include : Tag name
  • file : Tag parameter

Testing

This template engine build is animate by a complete regression test suite.

Notes

The simple template language is very close to JSP. It's based on underscore.

This project does not provide any advanced JSP tag. underscore. Compliant with Express. Add the tag include for HTML fragment.

Motivation

I do not like Jade or whatever short HTML template engine. I understand why it's a good solution for basic website. But it does not mix well with complex HTML + Javascript Framework like AngularJS. Also, I think software developer should generally minimize the number of transformation that must be done to produce an output.

Roadmap

  • Improve syntax error message
  • Speed optimization

Keywords

FAQs

Package last updated on 24 Sep 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc