node package manager
Don’t reinvent the wheel. Reuse code within your team. Create a free org »



Another Express view engine

$ npm install goat-node

(GOAT == 'Greatest of All Time') ? 'No..'

$ node example-app

for a quick example..

We were feeding goats at the petting zoo, and I thought about feeding data to an HTML template.

First of all, some reasons why another view/templating engine was worth a short time to put together.

Frankly, it gets no more straight-forward than,

Hello <?=$name?>, how are you..  

I don't use because unlike some people I don't like to type

NO template engine to reference or load, by the way..

Templating is just that, except usually with a strange new syntax to learn.
(The quality of which is entirely subjective by the way..)


Jade is good. Very nice. Terse == lovely. I wasn't crazy about having to learn it (Markdown either, as you can tell by the (!lovelyness) of my README), After some practice I can sort-of get stuff done. BUT I use two environments, Nodejs and PHP v5.2.
Jade for PHP v5.3> only, so says Mr. Google. :( I'm not upgrading my PHP right now.

Need something more old-school compatible.

Templates for every template engine I could find are not valid HTML. (Except Plates I believe)
Something just icky about that. I want to match on Div ids ala Plates. Small modules - not many features == good.

Logic, programming constructs in the template, wrong in both the academic and real worlds.

Custom syntaxes == more stuff to learn.

Expressjs styley..


var express = require('express'),
    app = express();
app.set('views', __dirname);
app.engine('html', require('goat-node'));
app.set('view engine', 'html');
app.all('/index.html', function(req, res) {
   // the template handles values and arrays only..  otherwise I gotta work thru dinnertime.. 
   res.render('index', {name:'Goat', people:[{name:'chris', age:42}, {name:'paris', age:32}]}
var port = process.env.PORT || 3000;
app.listen(port, function() {
  console.log("Listening on " + port);


<div id='name'></div>
<table id="">
      <tr id="people">
         <td id="name"></td>
         <td id="age"></td>

Should result in..

<div id="myid">Hello worlds!</div>
<table id="">
    <tr id="people">
       <td id="name">chris</td>
       <td id="age">42</td>
    <tr id="people">
       <td id="name">paris</td>
       <td id="age">32</td>

That's what I want.. and according to my wholly inadequate testing, that's what I now have..