Compare commits

..

No commits in common. "master" and "v2.0.7" have entirely different histories.

17 changed files with 985 additions and 17681 deletions

18
.gitignore vendored
View File

@ -1,20 +1,4 @@
.nogit/
# artifacts
node_modules/
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom

View File

@ -1,122 +1,144 @@
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
# gitzone standard
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: '$CI_BUILD_STAGE'
- .npmci_cache/
key: "$CI_BUILD_STAGE"
stages:
- security
- test
- release
- metadata
before_script:
- npm install -g @shipzone/npmci
- security
- test
- release
- metadata
# ====================
# security stage
# ====================
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
mirror:
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
- npmci git mirror
tags:
- docker
allow_failure: true
- docker
- notpriv
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=dev
- npmci command snyk test
tags:
- docker
- docker
- notpriv
sast:
stage: security
image: registry.gitlab.com/hosttoday/ht-docker-dbase:npmci
variables:
DOCKER_DRIVER: overlay2
allow_failure: true
services:
- docker:stable-dind
script:
- npmci npm prepare
- npmci npm install
- npmci command npm run build
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
--volume "$PWD:/code"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
artifacts:
reports:
sast: gl-sast-report.json
tags:
- docker
- priv
# ====================
# test stage
# ====================
testStable:
testLTS:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testBuild:
- docker
- notpriv
testSTABLE:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- lossless
- docker
- notpriv
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
only:
- tags
services:
- docker:stable-dind
script:
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
- 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:
- lossless
- docker
- priv
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- lossless
- docker
- notpriv
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci node install stable
- npmci command npm install -g typedoc typescript
- npmci npm prepare
- npmci npm install
- npmci command npm run buildDocs
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
tags:
- lossless
- docker
- notpriv
only:
@ -124,5 +146,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

4
.snyk Normal file
View File

@ -0,0 +1,4 @@
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
version: v1.13.3
ignore: {}
patch: {}

11
.vscode/launch.json vendored
View File

@ -1,11 +0,0 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}

26
.vscode/settings.json vendored
View File

@ -1,26 +0,0 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

40
README.md Normal file
View File

@ -0,0 +1,40 @@
# @pushrocks/smartmustache
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
[![build status](https://gitlab.com/pushrocks/smartmustache/badges/master/build.svg)](https://gitlab.com/pushrocks/smartmustache/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartmustache/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartmustache/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartmustache.svg)](https://www.npmjs.com/package/@pushrocks/smartmustache)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartmustache/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartmustache)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
## Usage
Use TypeScript for best in class instellisense.
```javascript
import { Tlt } from 'tlt';
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)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -3,26 +3,13 @@
"npmAccessLevel": "public"
},
"gitzone": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartmustache",
"description": "A library for creating and applying templates using Handlebars.",
"npmPackagename": "@push.rocks/smartmustache",
"license": "MIT",
"keywords": [
"templating",
"handlebars",
"text processing",
"data binding",
"code generation",
"string interpolation",
"dynamic content"
]
"shortDescription": "templates done right",
"npmPackagename": "@pushrocks/smartmustache",
"license": "MIT"
}
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
}
}

13463
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,57 +1,34 @@
{
"name": "@push.rocks/smartmustache",
"version": "3.0.2",
"description": "A library for creating and applying templates using Handlebars.",
"name": "@pushrocks/smartmustache",
"version": "2.0.7",
"description": "templates done right",
"private": false,
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web)",
"buildDocs": "tsdoc"
"test": "(tstest test/)",
"build": "(tsbuild)"
},
"repository": {
"type": "git",
"url": "https://code.foss.global/push.rocks/smartmustache.git"
"url": "git+ssh://git@gitlab.com/pushrocks/tlt.git"
},
"keywords": [
"templating",
"handlebars",
"text processing",
"data binding",
"code generation",
"string interpolation",
"dynamic content"
"template"
],
"author": "Lossless GmbH",
"license": "MIT",
"bugs": {
"url": "https://gitlab.com/pushrocks/tlt/issues"
},
"homepage": "https://code.foss.global/push.rocks/smartmustache",
"homepage": "https://gitlab.com/pushrocks/tlt#README",
"dependencies": {
"handlebars": "^4.7.7"
"handlebars": "^4.1.0"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.65",
"@gitzone/tsrun": "^1.2.37",
"@gitzone/tstest": "^1.0.73",
"@pushrocks/tapbundle": "^5.0.4"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}
"@gitzone/tsbuild": "^2.1.8",
"@gitzone/tsrun": "^1.1.17",
"@gitzone/tstest": "^1.0.18",
"@pushrocks/tapbundle": "^3.0.7"
}
}

4679
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@

153
readme.md
View File

@ -1,153 +0,0 @@
# @push.rocks/smartmustache
templates done right
## Install
To install `@push.rocks/smartmustache`, use npm:
```bash
npm install @push.rocks/smartmustache
```
Ensure you have Node.js and npm installed on your system before running the install command.
## Usage
To use `@push.rocks/smartmustache` in your project, follow these examples to understand how to integrate and utilize the library with its core functionalities. `@push.rocks/smartmustache` leverages Handlebars for templating, providing a seamless and efficient way to render dynamic content.
### Setting Up Your Project
First, ensure your project is set up to use ECMAScript modules (ESM) and TypeScript. Your `tsconfig.json` should include:
```json
{
"compilerOptions": {
"module": "ESNext",
"target": "es2020",
"moduleResolution": "node",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}
}
```
This setup will allow you to use ESM syntax in your TypeScript files efficiently.
### Basic Templating
Let's start with a basic example of using `@push.rocks/smartmustache` to apply data to a template string.
1. **Create a New Template Instance:**
First, import `SmartMustache` and create an instance by passing a template string to its constructor.
```typescript
import { SmartMustache } from '@push.rocks/smartmustache';
const template = 'Hello, {{name}}! Welcome to {{location}}.';
const myTemplate = new SmartMustache(template);
```
2. **Apply Data to the Template:**
Next, apply data to your template using the `applyData` method.
```typescript
const result = myTemplate.applyData({
name: 'John Doe',
location: 'SmartMustache World'
});
console.log(result); // Outputs: Hello, John Doe! Welcome to SmartMustache World.
```
### Advanced Usage
**Conditional Statements and Loops:**
Handlebars syntax allows for conditionals and loops. `@push.rocks/smartmustache` fully supports these Handlebars features.
- **Conditionals:**
Consider you have a template that should render content based on certain conditions.
```typescript
const conditionalTemplate = new SmartMustache(`
{{#if isAdmin}}
<p>Welcome, admin.</p>
{{else}}
<p>Welcome, user.</p>
{{/if}}
`);
console.log(conditionalTemplate.applyData({ isAdmin: true }));
```
- **Loops:**
Similarly, if you'd like to iterate over an array of items:
```typescript
const loopTemplate = new SmartMustache(`
<ul>
{{#each items}}
<li>{{this}}</li>
{{/each}}
</ul>
`);
console.log(loopTemplate.applyData({
items: ['Item 1', 'Item 2', 'Item 3']
}));
```
### Providing Helpers
`@push.rocks/smartmustache` allows integrating Handlebars helpers to extend templating capabilities.
```typescript
import Handlebars from 'handlebars';
// Register a Handlebars helper
Handlebars.registerHelper('uppercase', function(aString) {
return aString.toUpperCase();
});
const helperTemplate = new SmartMustache('Hello, {{uppercase name}}!');
console.log(helperTemplate.applyData({ name: 'john' })); // Outputs: Hello, JOHN!
```
### Reusing Templates
You can reuse an instance of `SmartMustache` by setting a new template string.
```typescript
myTemplate.setTemplate('Goodbye, {{name}}. See you in {{location}}.');
console.log(myTemplate.applyData({
name: 'Jane Doe',
location: 'the virtual world'
}));
```
### Conclusion
`@push.rocks/smartmustache` provides a powerful and intuitive way to work with templates in your TypeScript projects. By following these guides, you'll be able to implement dynamic content rendering seamlessly. The flexibility of Handlebars within a TypeScript-friendly wrapper accelerates development, ensuring your templates are both manageable and scalable.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@ -1,20 +1,20 @@
import { tap, expect } from '@pushrocks/tapbundle';
import * as tlt from '../ts/index.js';
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).toBeInstanceOf(tlt.SmartMustache);
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',
license: 'MIT'
});
expect(appliedString).toEqual('some awesome horse that is MIT licensed');
expect(appliedString).to.equal('some awesome horse that is MIT licensed');
});
tap.start();

View File

@ -1,8 +0,0 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/smartmustache',
version: '3.0.2',
description: 'templates done right'
}

View File

@ -1,4 +1,4 @@
import handlebars from 'handlebars';
import * as handlebars from 'handlebars';
/**
* class Tlt allows templates to be used with different sets of data

View File

@ -1,14 +0,0 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"verbatimModuleSyntax": true
},
"exclude": [
"dist_*/**/*.d.ts"
]
}

17
tslint.json Normal file
View File

@ -0,0 +1,17 @@
{
"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"
}