0.0.5-alpha • Published 2 years ago
@ghom/complate v0.0.5-alpha
@ghom/complate
Comment based templating engine
Installation
npm install @ghom/complateUsage
First, create a comment based template file with the following comment syntax: /** tag = js script **/ some data /** tag **/. Example:
<h1>Index</h1>
Date: <!-- date = new Date().toISOLocalString() --> 15/10/2024 <!-- date -->Here, the data between the date tags will be replaced with the result of the new Date().toISOLocalString() script.
Then, use the complate CLI to render the template:
complate index.htmlOr, use the complate function to render the template:
import { complate } from '@ghom/complate'
complate('index.html')After the render, the comments will not be removed, but the data between the tags will be replaced.
You can use a configuration file to define some presets for lighten the templating expression like that:
// complate.js
export function now() {
return new Date().toUTCString()
}And then, in a html file:
<!-- date = now --><!-- date -->0.0.5-alpha
2 years ago
0.0.4-alpha
2 years ago
0.0.3-alpha
2 years ago
0.0.2-alpha
2 years ago
0.0.1-alpha
2 years ago