mirror of
https://github.com/cupcakearmy/cometa.git
synced 2025-03-12 14:27:28 +00:00
1.3 KiB
1.3 KiB
Cometa
Yet another templating engine 📠
Cometa is a templating engine with no dependencies written in JS
. That was the reason because it was created.
Quickstart 💥
# Install
npm i cometa
# Run
node examples/simple/app.js
Setup 🏗
General Import
// Import
const Cometa = require('cometa')
// Initialize
const cometa = new Cometa()
Constructor parameters
views
[Optional] Root template folderextension
[Optional] File extension for the templatesencoding
[Optional] Encoding to be used on the
new Cometa({
views: './my/views/folder',
extension: 'html'
})
Installation 🚂
npm i cometa
Reference 📒
Variable
{myVar: "ok"}
<span>{{myVar}}</span>
Comments
<div>
{{# Me Me Comment #}}
</div>
If
True is everything that is different from:
undefined
false
null
''
{ myVar: 'something'|true|[1,2,3]|42|...}
{{? myVar }}
<span>Only show me when I exist: {{ myVar }}</span>
{{/?}}
Loop
{
links: [
{id:0, name: "One"},
{id:1, name: "Two"},
{id:2, name: "Three"}
]
}
<ul>
{{* link in links}}
<li id="{{link.id}}">{{ link.name }}</li>
{{/*}}
</ul>