Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c6a09e5f40 | |||
| 099d331fa7 | |||
| e6f9459fc8 | |||
| d25fe85fcd | |||
| 5ef057e31f | |||
| 494cb72d78 | |||
| 7b27b231ff | |||
| bd9ac0ab46 | |||
| 1c53edca7d | |||
| 6b279824fb | |||
| c06b8e6a18 | |||
| a707dff92d | |||
| 7bad738cb1 | |||
| 0e5db8f6b4 | |||
| deadd463de | |||
| e783dcb1f8 | |||
|
|
62cacffe61 | ||
|
|
df76935a52 | ||
| f078653846 | |||
| 50d70eaece | |||
| 452f086d84 | |||
| 0113d8ea19 | |||
| a5a8f5ae24 | |||
| 01ad44078c | |||
| f846505fab | |||
| 6e5e1bb631 |
20
.gitignore
vendored
20
.gitignore
vendored
@@ -1,4 +1,22 @@
|
|||||||
node_modules/
|
.nogit/
|
||||||
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
||||||
113
.gitlab-ci.yml
113
.gitlab-ci.yml
@@ -1,59 +1,118 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone ci_default
|
||||||
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- metadata
|
||||||
- pages
|
|
||||||
|
|
||||||
testLEGACY:
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
|
|
||||||
|
testStable:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
allow_failure: true
|
- priv
|
||||||
|
|
||||||
testLTS:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci npm prepare
|
||||||
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command npm run build
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci test stable
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci publish
|
- npmci node install stable
|
||||||
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# metadata stage
|
||||||
|
# ====================
|
||||||
|
codequality:
|
||||||
|
stage: metadata
|
||||||
|
allow_failure: true
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g tslint typescript
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- priv
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: trigger
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci trigger
|
- npmci trigger
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmpage
|
stage: metadata
|
||||||
stage: pages
|
|
||||||
script:
|
script:
|
||||||
- npmci command npmpage --host gitlab
|
- npmci node install lts
|
||||||
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command tsdoc
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
|||||||
4
.snyk
Normal file
4
.snyk
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||||
|
version: v1.13.3
|
||||||
|
ignore: {}
|
||||||
|
patch: {}
|
||||||
41
README.md
41
README.md
@@ -1,15 +1,40 @@
|
|||||||
# tlt
|
# @pushrocks/smartmustache
|
||||||
templates done right
|
templates done right
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartmustache)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartmustache)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/smartmustache)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartmustache/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/smartmustache/commits/master)
|
||||||
|
[](https://gitlab.com/pushrocks/smartmustache/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@pushrocks/smartmustache)
|
||||||
|
[](https://snyk.io/test/npm/@pushrocks/smartmustache)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
We recommend the use of TypeScript for best in class Intellisense
|
|
||||||
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import { Tlt } from 'tlt'
|
import { SmartMustache } from '@pushrocks/smartmustache';
|
||||||
|
|
||||||
let myTlt = new Tlt('my template String for {{somePlaceholder}} and {{anotherPlaceholder}}')
|
const mySmartmustache = new SmartMustache('my {{somePlaceholder}} are {{anotherPlaceholder}}!');
|
||||||
myTlt.getStringFor({
|
const appliedString = myTlt.applyData({
|
||||||
"somePlaceholder": "pushrocks",
|
somePlaceholder: 'horses',
|
||||||
"anotherPlaceholder": "anotherPlaceholder"
|
anotherPlaceholder: 'awesome'
|
||||||
})
|
});
|
||||||
|
|
||||||
|
// appliedString will be 'my horses are awesome!'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
||||||
|
|||||||
18
dist/index.d.ts
vendored
18
dist/index.d.ts
vendored
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* class Tlt allows templates to be used with different sets of data
|
|
||||||
*/
|
|
||||||
export declare class Tlt {
|
|
||||||
templateString: string;
|
|
||||||
/**
|
|
||||||
* constructor of class Tlt
|
|
||||||
*/
|
|
||||||
constructor(templateStringArg: string);
|
|
||||||
/**
|
|
||||||
* returns template string with data applied
|
|
||||||
*/
|
|
||||||
applyData(data: any): string;
|
|
||||||
/**
|
|
||||||
* set a new template string
|
|
||||||
*/
|
|
||||||
setTemplate(templateStringArg: string): void;
|
|
||||||
}
|
|
||||||
27
dist/index.js
vendored
27
dist/index.js
vendored
@@ -1,27 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
const mustache = require("mustache");
|
|
||||||
/**
|
|
||||||
* class Tlt allows templates to be used with different sets of data
|
|
||||||
*/
|
|
||||||
class Tlt {
|
|
||||||
/**
|
|
||||||
* constructor of class Tlt
|
|
||||||
*/
|
|
||||||
constructor(templateStringArg) {
|
|
||||||
this.templateString = templateStringArg;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* returns template string with data applied
|
|
||||||
*/
|
|
||||||
applyData(data) {
|
|
||||||
return mustache.render(this.templateString, data);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* set a new template string
|
|
||||||
*/
|
|
||||||
setTemplate(templateStringArg) {
|
|
||||||
this.templateString = templateStringArg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.Tlt = Tlt;
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEscUNBQW9DO0FBRXBDOztHQUVHO0FBQ0g7SUFHSTs7T0FFRztJQUNILFlBQVksaUJBQXlCO1FBQ2pDLElBQUksQ0FBQyxjQUFjLEdBQUcsaUJBQWlCLENBQUE7SUFDM0MsQ0FBQztJQUVEOztPQUVHO0lBQ0gsU0FBUyxDQUFDLElBQVM7UUFDZixNQUFNLENBQUMsUUFBUSxDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsY0FBYyxFQUFFLElBQUksQ0FBQyxDQUFBO0lBQ3JELENBQUM7SUFFRDs7T0FFRztJQUNILFdBQVcsQ0FBQyxpQkFBeUI7UUFDakMsSUFBSSxDQUFDLGNBQWMsR0FBRyxpQkFBaUIsQ0FBQTtJQUMzQyxDQUFDO0NBQ0o7QUF2QkQsa0JBdUJDIn0=
|
|
||||||
15
npmextra.json
Normal file
15
npmextra.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "smartmustache",
|
||||||
|
"shortDescription": "templates done right",
|
||||||
|
"npmPackagename": "@pushrocks/smartmustache",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1576
package-lock.json
generated
Normal file
1576
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
package.json
32
package.json
@@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "tlt",
|
"name": "@pushrocks/smartmustache",
|
||||||
"version": "1.0.2",
|
"version": "2.0.9",
|
||||||
"description": "templates done right",
|
"description": "templates done right",
|
||||||
|
"private": false,
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(npmts)"
|
"test": "(tstest test/)",
|
||||||
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -21,13 +23,23 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/tlt#README",
|
"homepage": "https://gitlab.com/pushrocks/tlt#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/mustache": "^0.8.29",
|
"handlebars": "^4.7.1"
|
||||||
"mustache": "^2.3.0",
|
|
||||||
"typings-global": "^1.0.14"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/should": "^8.1.30",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"should": "^11.1.1",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"typings-test": "^1.0.3"
|
"@gitzone/tstest": "^1.0.28",
|
||||||
}
|
"@pushrocks/tapbundle": "^3.2.0"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_web/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
1
test/test.d.ts
vendored
1
test/test.d.ts
vendored
@@ -1 +0,0 @@
|
|||||||
import 'typings-test';
|
|
||||||
16
test/test.js
16
test/test.js
@@ -1,16 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
require("typings-test");
|
|
||||||
const should = require("should");
|
|
||||||
const tlt = require("../dist/index");
|
|
||||||
describe('tlt', function () {
|
|
||||||
let testTlt;
|
|
||||||
it('should create a valid instance of tlt', function () {
|
|
||||||
testTlt = new tlt.Tlt('some awesome {{customString}}');
|
|
||||||
should(testTlt).be.instanceOf(tlt.Tlt);
|
|
||||||
});
|
|
||||||
it('should output a valid string with some data', function () {
|
|
||||||
let appliedString = testTlt.applyData({ customString: 'horse' });
|
|
||||||
should(appliedString).equal('some awesome horse');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixpQ0FBZ0M7QUFFaEMscUNBQW9DO0FBRXBDLFFBQVEsQ0FBQyxLQUFLLEVBQUU7SUFDWixJQUFJLE9BQWdCLENBQUE7SUFDcEIsRUFBRSxDQUFDLHVDQUF1QyxFQUFFO1FBQ3hDLE9BQU8sR0FBRyxJQUFJLEdBQUcsQ0FBQyxHQUFHLENBQUMsK0JBQStCLENBQUMsQ0FBQTtRQUN0RCxNQUFNLENBQUMsT0FBTyxDQUFDLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7SUFDMUMsQ0FBQyxDQUFDLENBQUE7SUFDRixFQUFFLENBQUMsNkNBQTZDLEVBQUU7UUFDOUMsSUFBSSxhQUFhLEdBQUcsT0FBTyxDQUFDLFNBQVMsQ0FBQyxFQUFDLFlBQVksRUFBRSxPQUFPLEVBQUMsQ0FBQyxDQUFBO1FBQzlELE1BQU0sQ0FBQyxhQUFhLENBQUMsQ0FBQyxLQUFLLENBQUMsb0JBQW9CLENBQUMsQ0FBQTtJQUNyRCxDQUFDLENBQUMsQ0FBQTtBQUNOLENBQUMsQ0FBQyxDQUFBIn0=
|
|
||||||
32
test/test.ts
32
test/test.ts
@@ -1,16 +1,20 @@
|
|||||||
import 'typings-test'
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
import * as should from 'should'
|
|
||||||
|
|
||||||
import * as tlt from '../dist/index'
|
import * as tlt from '../ts/index';
|
||||||
|
|
||||||
describe('tlt', function() {
|
let testMustache: tlt.SmartMustache;
|
||||||
let testTlt: tlt.Tlt
|
tap.test('should create a valid instance of tlt', async () => {
|
||||||
it('should create a valid instance of tlt', function() {
|
testMustache = new tlt.SmartMustache(
|
||||||
testTlt = new tlt.Tlt('some awesome {{customString}}')
|
'some awesome {{customString}} that is {{license}} licensed'
|
||||||
should(testTlt).be.instanceOf(tlt.Tlt)
|
);
|
||||||
})
|
expect(testMustache).to.be.instanceOf(tlt.SmartMustache);
|
||||||
it('should output a valid string with some data', function(){
|
});
|
||||||
let appliedString = testTlt.applyData({customString: 'horse'})
|
tap.test('should output a valid string with some data', async () => {
|
||||||
should(appliedString).equal('some awesome horse')
|
let appliedString = testMustache.applyData({
|
||||||
})
|
customString: 'horse',
|
||||||
})
|
license: 'MIT'
|
||||||
|
});
|
||||||
|
expect(appliedString).to.equal('some awesome horse that is MIT licensed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
|
|||||||
42
ts/index.ts
42
ts/index.ts
@@ -1,29 +1,29 @@
|
|||||||
import * as mustache from 'mustache'
|
import * as handlebars from 'handlebars';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class Tlt allows templates to be used with different sets of data
|
* class Tlt allows templates to be used with different sets of data
|
||||||
*/
|
*/
|
||||||
export class Tlt {
|
export class SmartMustache {
|
||||||
templateString: string
|
template: any;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor of class Tlt
|
* constructor of class Tlt
|
||||||
*/
|
*/
|
||||||
constructor(templateStringArg: string) {
|
constructor(templateStringArg: string) {
|
||||||
this.templateString = templateStringArg
|
this.template = handlebars.compile(templateStringArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns template string with data applied
|
* returns template string with data applied
|
||||||
*/
|
*/
|
||||||
applyData(data: any): string {
|
applyData(data: any): string {
|
||||||
return mustache.render(this.templateString, data)
|
return this.template(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set a new template string
|
* set a new template string
|
||||||
*/
|
*/
|
||||||
setTemplate(templateStringArg: string) {
|
setTemplate(templateStringArg: string) {
|
||||||
this.templateString = templateStringArg
|
this.template = handlebars.compile(templateStringArg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
tslint.json
16
tslint.json
@@ -1,3 +1,17 @@
|
|||||||
{
|
{
|
||||||
"extends": "tslint-config-standard"
|
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||||
|
"rules": {
|
||||||
|
"semicolon": [true, "always"],
|
||||||
|
"no-console": false,
|
||||||
|
"ordered-imports": false,
|
||||||
|
"object-literal-sort-keys": false,
|
||||||
|
"member-ordering": {
|
||||||
|
"options":{
|
||||||
|
"order": [
|
||||||
|
"static-method"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"defaultSeverity": "warning"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user