Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1c53edca7d | |||
| 6b279824fb | |||
| c06b8e6a18 | |||
| a707dff92d | |||
| 7bad738cb1 | |||
| 0e5db8f6b4 | |||
| deadd463de | |||
| e783dcb1f8 | |||
|
|
62cacffe61 | ||
|
|
df76935a52 | ||
| f078653846 | |||
| 50d70eaece | |||
| 452f086d84 | |||
| 0113d8ea19 | |||
| a5a8f5ae24 | |||
| 01ad44078c | |||
| f846505fab | |||
| 6e5e1bb631 | |||
| de578b3123 | |||
| 450ee5162c |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
node_modules/
|
||||||
|
coverage/
|
||||||
|
public/
|
||||||
|
pages/
|
||||||
121
.gitlab-ci.yml
121
.gitlab-ci.yml
@@ -1,59 +1,142 @@
|
|||||||
image: hosttoday/ht-docker-node:npmts
|
# gitzone standard
|
||||||
|
image: hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
|
cache:
|
||||||
|
paths:
|
||||||
|
- .npmci_cache/
|
||||||
|
key: "$CI_BUILD_STAGE"
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
|
- security
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
- trigger
|
- metadata
|
||||||
- pages
|
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# security stage
|
||||||
|
# ====================
|
||||||
|
mirror:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci git mirror
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
snyk:
|
||||||
|
stage: security
|
||||||
|
script:
|
||||||
|
- npmci command npm install -g snyk
|
||||||
|
- npmci command npm install --ignore-scripts
|
||||||
|
- npmci command snyk test
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
|
# ====================
|
||||||
|
# test stage
|
||||||
|
# ====================
|
||||||
testLEGACY:
|
testLEGACY:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test legacy
|
- npmci node install legacy
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
|
||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test lts
|
- npmci node install lts
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
testSTABLE:
|
testSTABLE:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci test stable
|
- npmci node install stable
|
||||||
|
- npmci npm install
|
||||||
|
- npmci npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
- notpriv
|
||||||
|
|
||||||
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
|
||||||
|
image: docker:stable
|
||||||
|
allow_failure: true
|
||||||
|
services:
|
||||||
|
- docker:stable-dind
|
||||||
|
script:
|
||||||
|
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
||||||
|
- docker run
|
||||||
|
--env SOURCE_CODE="$PWD"
|
||||||
|
--volume "$PWD":/code
|
||||||
|
--volume /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
||||||
|
artifacts:
|
||||||
|
paths: [codeclimate.json]
|
||||||
|
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
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: pages
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npmpage --host gitlab
|
- npmci command npm install -g typedoc typescript
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
- notpriv
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
artifacts:
|
artifacts:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
windowsCompatibility:
|
||||||
|
image: stefanscherer/node-windows:10-build-tools
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npm install & npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- windows
|
||||||
|
allow_failure: true
|
||||||
|
|||||||
38
README.md
38
README.md
@@ -1,15 +1,41 @@
|
|||||||
# tlt
|
# tlt
|
||||||
templates done right
|
templates done right
|
||||||
|
|
||||||
|
## Availabililty
|
||||||
|
[](https://www.npmjs.com/package/tlt)
|
||||||
|
[](https://GitLab.com/pushrocks/tlt)
|
||||||
|
[](https://github.com/pushrocks/tlt)
|
||||||
|
[](https://pushrocks.gitlab.io/tlt/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://GitLab.com/pushrocks/tlt/commits/master)
|
||||||
|
[](https://GitLab.com/pushrocks/tlt/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/tlt)
|
||||||
|
[](https://david-dm.org/pushrocks/tlt)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/tlt/master/dependencies/npm)
|
||||||
|
[](https://www.bithound.io/github/pushrocks/tlt)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
||||||
|
[](http://standardjs.com/)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
We recommend the use of TypeScript for best in class Intellisense
|
Use TypeScript for best in class instellisense.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import * as tlt from 'tlt
|
import { Tlt } from 'tlt'
|
||||||
|
|
||||||
let myTlt = new tlt('my template String for {{somePlaceholder}} and {{anotherPlaceholder}}')
|
let myTlt = new Tlt('my {{somePlaceholder}} are {{anotherPlaceholder}}!')
|
||||||
myTlt.getStringFor({
|
let 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.html)
|
||||||
|
|
||||||
|
[](https://push.rocks)
|
||||||
|
|||||||
5
npmextra.json
Normal file
5
npmextra.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"npmci": {
|
||||||
|
"npmAccessLevel": "public"
|
||||||
|
}
|
||||||
|
}
|
||||||
1463
package-lock.json
generated
Normal file
1463
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "tlt",
|
"name": "@pushrocks/smartmustache",
|
||||||
"version": "1.0.1",
|
"version": "2.0.5",
|
||||||
"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",
|
||||||
@@ -19,5 +21,14 @@
|
|||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/tlt/issues"
|
"url": "https://gitlab.com/pushrocks/tlt/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/tlt#README"
|
"homepage": "https://gitlab.com/pushrocks/tlt#README",
|
||||||
|
"dependencies": {
|
||||||
|
"handlebars": "^4.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@gitzone/tsbuild": "^2.1.8",
|
||||||
|
"@gitzone/tsrun": "^1.1.17",
|
||||||
|
"@gitzone/tstest": "^1.0.18",
|
||||||
|
"@pushrocks/tapbundle": "^3.0.7"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
test/test.ts
Normal file
18
test/test.ts
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
import { tap, expect } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
|
import * as tlt from '../ts/index';
|
||||||
|
|
||||||
|
let testMustache: tlt.SmartMustache;
|
||||||
|
tap.test('should create a valid instance of tlt', async () => {
|
||||||
|
testMustache = new tlt.SmartMustache('some awesome {{customString}} that is {{license}} licensed');
|
||||||
|
expect(testMustache).to.be.instanceOf(tlt.SmartMustache);
|
||||||
|
});
|
||||||
|
tap.test('should output a valid string with some data', async () => {
|
||||||
|
let appliedString = testMustache.applyData({
|
||||||
|
customString: 'horse',
|
||||||
|
license: 'MIT'
|
||||||
|
});
|
||||||
|
expect(appliedString).to.equal('some awesome horse that is MIT licensed');
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.start();
|
||||||
29
ts/index.ts
Normal file
29
ts/index.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import * as handlebars from 'handlebars';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class Tlt allows templates to be used with different sets of data
|
||||||
|
*/
|
||||||
|
export class SmartMustache {
|
||||||
|
template: any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* constructor of class Tlt
|
||||||
|
*/
|
||||||
|
constructor(templateStringArg: string) {
|
||||||
|
this.template = handlebars.compile(templateStringArg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns template string with data applied
|
||||||
|
*/
|
||||||
|
applyData(data: any): string {
|
||||||
|
return this.template(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set a new template string
|
||||||
|
*/
|
||||||
|
setTemplate(templateStringArg: string) {
|
||||||
|
this.template = handlebars.compile(templateStringArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user