A html template engine design to create web apps.
npm install fastappA html template engine design to create web apps.





npm install fastapp
- Complies with the Express web rooter.
- Mark command tag using#{ code /}
The markup language is composed of tag of this form:
#{command first_Arg, second_Arg, ... /}
The available commands are:
- __set__: Assign the value of the expression(2) to the variable name(1).
- __get__: Replace this tag by the value of the expression(1).
- __get_if__: If the condition(1) is true, replace this tag by the value of the expression(2) else by the second expression(3).
- __include__: Insert the content of the file indicate by the value of the expression(1).
- __doLayout___: Insert the content of the child template.
- __extends___: Define the parent of this template (see extends).
`` Bienvenue sur #{get title/}html`
#{set title,'MyPage' /}
#{set menu,'home' /}
#{extends '/model.html' /}...
#{include '/menu-' + menu + '.html' /}
You can use this script of three different ways.
On command line:
> node lib/fastapp.js [html_file]
On your script:
`js`
var fapp = require ('fastapp')
fapp.buildFile(path, null, function (err, data) {
//...
});
Using Express:
`js
var fapp = require('fastapp'),
express = require('express'),
app = express(),
option = { / ... / }
// What's on /dist folder is freely accessible
app.get('/dist', express.static(__dirname + '/dist'));
// For the rest, we use the engine
app.get('/views', fapp.lookAt(__dirname + '/views', option));
app.listen(80);
`
- cache If true, will keep static page into memory.params
- Array of values accessible via params.namequery
- Array of values accessible via params.querydebug
- Output debug informationopen
- Open tag, defaulting to "#{close
- Closing tag, defaulting to "/}"directory
- Change of directory (default is ./views)
A real advantage about this template is to insert content of other pages.
You have two way of doing this, the extends and include commands.
The extends allow to define a parent. This is always the last executed command on the page.
##### ./views/model.html
`html`
...
...
#{include '/menu.html' /}
#{doLayout /}
##### ./views/index.html This is my page
`html`
#{set title 'MyPage' /}
#{set menu, 'home' /}
#{extends '/models.html' /}Welcome #{get_if query.user!=null, query.user, 'new visitor'}!
##### ./views/menu.html
`html`
##### RENDER (indentation corrected) /index.html?user=Fab This is my page
`html``
...
...
Welcome Fab!
[1]: http://expressjs.com