pjs-node

0.0.4 • Public • Published

pjs-node

Here was the problem.. I want templates that will work in both PHP and NodeJS-ExpressJS..
I like to template in PHP the simple way.. like this..

some.php
<?
  $s = "World"
?> 
 
Hello <?=$s?>

Now this template can be used in Express like this..

app.js
var  express = require('express')
        ,app = express();
 
app.set('view engine', 'pjs')
app.engine('pjs', require('./index.js'))
 
var o = { name:'Chris', greeting:'how are you' }
 
app.get('/mustache', function(req,res){
    res.render("index-mustache", o);
})
 
app.get('/', function(req,res){
    res.render("index-pjs", o);
})
  
app.listen(3000)

Mustache can be used instead, but partials are not supported

Templates have an .pjs extension and are in /views

See test.js for examples

Readme

Keywords

none

Package Sidebar

Install

npm i pjs-node

Weekly Downloads

4

Version

0.0.4

License

none

Last publish

Collaborators

  • dpweb