Splatter
A quicker, unopinionated template engine for Express.js
Write server-side JavaScript inside HTML using a code block:
filename.splat
*{ title = 'Oh look...'; colors = ['Red', 'Blue', 'Green'];}...
Output JavaScript variables:
*title
Use parenthisis if needed:
*(title + ' colors.')
Loop just like in JavaScript:
*for (color in colors) { *color}
Conditions:
*if (title.length > 3) { *title}
Make comments anywhere:
*[ I'm feeling blue ]
Here's an example:
index.splat
*{ title = 'Oh look...'; colors = ['Red', 'Blue', 'Green'];} *(title + ' colors.') *[I'm feeling blue] *for (color in colors) { *colors[color] }
Express Example
Here's an example of how to set up with express:
const express =const splatter = ;const app =appapp // specify the views directoryapp // register the template engineappvar port = 3000;app
Use *input.title
to output variables passed to the template.