Templating Engine
Go to file
nicco 41269a07ed wrong include 2018-02-22 10:38:01 +01:00
dist Dist Render 2018-02-21 12:30:59 +01:00
examples wrong include 2018-02-22 10:38:01 +01:00
src Support for brakets 2018-02-21 12:30:43 +01:00
test Testing 2018-02-21 19:39:15 +01:00
.gitignore Ignroe Files 2018-02-22 10:33:01 +01:00
.npmignore wrong include 2018-02-22 10:38:01 +01:00
.travis.yml Add Travis File 2018-02-21 19:42:44 +01:00
README.md Update README.md 2018-02-21 19:45:17 +01:00
package.json Version bump 2018-02-22 10:12:48 +01:00
tsconfig.json Include src and output to dist 2018-02-07 11:46:08 +01:00

README.md

Cometa

Build Status

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 folder
  • extension [Optional] File extension for the templates
  • encoding [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",
	"myVar": true,
	"myVar": [1,2,3],
	"myVar": 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>