Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b27b231ff | |||
| bd9ac0ab46 | |||
| 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/
|
||||
105
.gitlab-ci.yml
105
.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:
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- trigger
|
||||
- pages
|
||||
- metadata
|
||||
|
||||
# ====================
|
||||
# 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:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test legacy
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test lts
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci test stable
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
script:
|
||||
- npmci publish
|
||||
- npmci node install stable
|
||||
- npmci npm publish
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- 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:
|
||||
stage: trigger
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci trigger
|
||||
only:
|
||||
- tags
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
pages:
|
||||
image: hosttoday/ht-docker-node:npmpage
|
||||
stage: pages
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
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:
|
||||
- tags
|
||||
artifacts:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- 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
|
||||
|
||||
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: {}
|
||||
38
README.md
38
README.md
@@ -1,15 +1,41 @@
|
||||
# tlt
|
||||
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
|
||||
We recommend the use of TypeScript for best in class Intellisense
|
||||
Use TypeScript for best in class instellisense.
|
||||
|
||||
```javascript
|
||||
import * as tlt from 'tlt
|
||||
import { Tlt } from 'tlt'
|
||||
|
||||
let myTlt = new tlt('my template String for {{somePlaceholder}} and {{anotherPlaceholder}}')
|
||||
myTlt.getStringFor({
|
||||
"somePlaceholder": "pushrocks",
|
||||
"anotherPlaceholder": "anotherPlaceholder"
|
||||
let myTlt = new Tlt('my {{somePlaceholder}} are {{anotherPlaceholder}}!')
|
||||
let appliedString = myTlt.applyData({
|
||||
"somePlaceholder": "horses",
|
||||
"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",
|
||||
"version": "1.0.1",
|
||||
"name": "@pushrocks/smartmustache",
|
||||
"version": "2.0.6",
|
||||
"description": "templates done right",
|
||||
"private": false,
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"test": "(npmts)"
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -19,5 +21,14 @@
|
||||
"bugs": {
|
||||
"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