update tsconfig
This commit is contained in:
parent
fc3b3d38aa
commit
5a3da93578
@ -8,12 +8,21 @@
|
||||
"githost": "code.foss.global",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "smartmustache",
|
||||
"description": "templates done right",
|
||||
"description": "A library for creating and applying templates using Handlebars.",
|
||||
"npmPackagename": "@push.rocks/smartmustache",
|
||||
"license": "MIT"
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"templating",
|
||||
"handlebars",
|
||||
"text processing",
|
||||
"data binding",
|
||||
"code generation",
|
||||
"string interpolation",
|
||||
"dynamic content"
|
||||
]
|
||||
}
|
||||
},
|
||||
"tsdocs": {
|
||||
"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"
|
||||
}
|
||||
}
|
10
package.json
10
package.json
@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@push.rocks/smartmustache",
|
||||
"version": "3.0.2",
|
||||
"description": "templates done right",
|
||||
"description": "A library for creating and applying templates using Handlebars.",
|
||||
"private": false,
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
@ -16,7 +16,13 @@
|
||||
"url": "git+ssh://git@gitlab.com/pushrocks/tlt.git"
|
||||
},
|
||||
"keywords": [
|
||||
"template"
|
||||
"templating",
|
||||
"handlebars",
|
||||
"text processing",
|
||||
"data binding",
|
||||
"code generation",
|
||||
"string interpolation",
|
||||
"dynamic content"
|
||||
],
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
|
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
||||
|
172
readme.md
172
readme.md
@ -1,51 +1,153 @@
|
||||
# @pushrocks/smartmustache
|
||||
# @push.rocks/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/)
|
||||
## Install
|
||||
|
||||
## Status for master
|
||||
To install `@push.rocks/smartmustache`, use npm:
|
||||
|
||||
Status Category | Status Badge
|
||||
-- | --
|
||||
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartmustache/badges/master/pipeline.svg)](https://lossless.cloud)
|
||||
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartmustache/badges/master/coverage.svg)](https://lossless.cloud)
|
||||
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartmustache)](https://lossless.cloud)
|
||||
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartmustache)](https://lossless.cloud)
|
||||
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
|
||||
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
|
||||
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartmustache)](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartmustache)](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartmustache)](https://lossless.cloud)
|
||||
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
|
||||
```bash
|
||||
npm install @push.rocks/smartmustache
|
||||
```
|
||||
|
||||
Ensure you have Node.js and npm installed on your system before running the install command.
|
||||
|
||||
## Usage
|
||||
|
||||
Use TypeScript for best in class instellisense.
|
||||
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.
|
||||
|
||||
```javascript
|
||||
import { SmartMustache } from '@pushrocks/smartmustache';
|
||||
### Setting Up Your Project
|
||||
|
||||
const mySmartmustache = new SmartMustache('my {{somePlaceholder}} are {{anotherPlaceholder}}!');
|
||||
const appliedString = myTlt.applyData({
|
||||
somePlaceholder: 'horses',
|
||||
anotherPlaceholder: 'awesome',
|
||||
});
|
||||
First, ensure your project is set up to use ECMAScript modules (ESM) and TypeScript. Your `tsconfig.json` should include:
|
||||
|
||||
// appliedString will be 'my horses are awesome!'
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "es2020",
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Contribution
|
||||
This setup will allow you to use ESM syntax in your TypeScript files efficiently.
|
||||
|
||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||
### Basic Templating
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
Let's start with a basic example of using `@push.rocks/smartmustache` to apply data to a template string.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
1. **Create a New Template Instance:**
|
||||
|
||||
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user