Component-like template engine.
The recommended way to use compot is using gulp plugin.
(sudo) npm install -g compot
compot src dest
var compot = require('compot'),
fs = require('fs');
var src = fs.readFileSync('path/to/src', 'utf8');
compot.render(src, {
root: 'path/to/root'
}, function(err, res){
fs.writeFileSync(res, 'path/to/dest', 'utf8');
});
return converted html string.
name | type | description |
---|---|---|
source | string | source html string |
option | Object | options(optional) |
option.root | string | root directory which is used in resolving import compot file |
callback | Function | called as callback(Error, string) |
<!-- main.html -->
<link rel="compot" href="./my-tag.html">
<my-tag class="foo" title="Compot!">
This is <b>my custom tag</b>
</my-tag>
<!-- my-tag.html -->
<template type="compot" name="my-tag">
<div class="buz">
<header>{{title}}</header>
<p>
<content></content>
</p>
</div>
</template>
# CLI
compot ./main.html ./build.html
The output is,
<!-- build.html -->
<div class="buz foo">
<header>Compot!</header>
<p>
This is <b>my custom tag</b>
</p>
</div>