0.2.6 • Published 5 years ago
@encores/formatter v0.2.6
Formatter
A simply formatter for any Articles and News
Install
npm i @encores/formatter
# or
yarn add @encores/formatter
Get Started
// Import Formatter Package
import Formatter from "@encores/formatter";
/* Import Formatter Style */
@import url("@encores/formatter");
How to Use ?
1. Initialize
// Set Styles of Formatter
const formatterOption = {
global: {
color: `black`
},
title: {
color: `tomato`
},
section: {
color: `dimgray`
}
};
// Set Custom Template
const formatterTemplate = `
<div class="formatter">\
{{= it.name }}
{{? it.title }}
<h1 class="title">{{= it.title }}</h1>\
{{? }}
{{? it.author || it.time }}
<div>\
{{? it.author }}
<span class="author">{{= it.author }}</span>\
{{? }}
{{? it.time }}
<span class="time">{{= it.time }}</span>\
{{? }}
</div>\
{{? }}
<article class="section">\
{{~ it.section:item:index }}\
<p>{{= item }}</p>\
{{~ }}\
</article>\
</div>\
`;
// Instantiate Formatter
const formatter = new Formatter(formatterOption, () => formatterTemplate);
2. Compile
// Wrap Necessary Tags -- Plain Text Only
const content = `<h1>${title}</h1><div>${content}</div>`;
// Compile
const article = formatter.compile(content);
or Precise
const article = formatter.compile({
title: `How to use Formatter ?`,
content: `This is a manual on how to use Formatter`,
author: `joenix`,
time: `0516.2020`,
name() {
return `<span>name</span>`;
}
});
0.2.6
5 years ago
0.2.5
5 years ago
0.2.4
5 years ago
0.2.3
5 years ago
0.2.1
5 years ago
0.2.2
5 years ago
0.1.10
5 years ago
0.1.9
5 years ago
0.1.8
5 years ago
0.1.7
5 years ago
0.1.4
5 years ago
0.1.6
5 years ago
0.1.5
5 years ago
0.1.3
5 years ago
0.0.10
5 years ago
0.1.2
5 years ago
0.0.9
5 years ago
0.0.8
6 years ago
0.0.5
6 years ago
0.0.7
6 years ago
0.0.6
6 years ago
0.0.4
6 years ago
0.0.3
6 years ago
0.0.2
6 years ago
0.0.1
6 years ago