1.3.4 • Published 8 years ago
tclibs v1.3.4
tclibs
General purpose libraries
string
var tcstring = require('tclibs/lib/string');
tcstring.fillSpace(string, length[, char, left]);
tcstring.fillSpace('tst', 5);
// tst
tcstring.fillSpace('tst', 5, '_');
// tst__
tcstring.fillSpace('tst', 5, '_', true);
// __tst
date
var tcdate = require('tclibs/lib/date');
console.log(tcdate.today + '');
// '22/10/2016'
tcdate.datechar = '-' // '22-10-2016'
console.log(tcdate.today + '');
// '22-10-2016'
tcdate.dateorder = ['year', 'day', 'month'];
console.log(tcdate.today + '');
// '2016-22-10'
uri
var tcuri = require('tclibs/lib/uri');
tcuri.getParams('https://github.com/TorijaCarlos/libraries.js?tst=1&exc=hola');
// { 'tst': 1, 'exc': 'hola' }
xml
var tcxml = require('tclibs/lib/xml');
new tcxml.JSON({
el: {
div: {
ul: [
{li: 'ELEMENT 1'},
{li: 'ELEMENT 2'},
{li: 'ELEMENT 3'},
{li: 'ELEMENT 4'},
{li: 'ELEMENT 5'},
],
},
},
}) + '';
new tcxml.Node({
el: 'div',
attr: { class: 'row container' },
subnodes: [
new tcxml.Node({
el: 'input',
attr: {
class: 'form-input',
value: 'tst'
},
selfclose: true
}),
],
}) + '';
new tcxml.Table({
rows: [{
attr: { class: 'table-header' },
cols: [{
innertext: 'Header 1'
}, {
innertext: 'Header 2'
}]
}, {
attr: { class: 'table-row-1' },
cols: [{
innertext: 'Column 1'
}, {
innertext: 'Column 2'
}]
}],
}) + ''