# cross-tpl

> ``` ts import { CrossTpl } from 'cross-tpl'

Latest version **1.3.9** (published 2020-09-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install cross-tpl
pnpm add cross-tpl
yarn add cross-tpl
bun add cross-tpl
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.3.9 |
| Published | 2020-09-17 |
| First published | 2020-04-03 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 19 |
| Unpacked size | 319.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | usemint |

## Links

- npm: https://www.npmjs.com/package/cross-tpl
- Repository: https://github.com/devleatherks/cross-tpl-js
- Homepage: https://github.com/devleatherks/cross-tpl-js#readme
- Issues: https://github.com/devleatherks/cross-tpl-js/issues
- npm.io page: https://npm.io/package/cross-tpl

## Dependencies (19)

- [md5](https://npm.io/package/md5.md) ^2.2.1
- [ora](https://npm.io/package/ora.md) ^4.0.4
- [btoa](https://npm.io/package/btoa.md) ^1.2.1
- [gulp](https://npm.io/package/gulp.md) ^4.0.0
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [ts-md5](https://npm.io/package/ts-md5.md) ^1.2.7
- [consola](https://npm.io/package/consola.md) ^2.11.3
- [cli-step](https://npm.io/package/cli-step.md) ^1.0.2
- [js-base64](https://npm.io/package/js-base64.md) ^2.5.2
- [@types/md5](https://npm.io/package/@types/md5.md) ^2.1.33
- [gulp-watch](https://npm.io/package/gulp-watch.md) ^5.0.1
- [typescript](https://npm.io/package/typescript.md) ^3.8.3
- [@types/gulp](https://npm.io/package/@types/gulp.md) ^4.0.6
- [@types/node](https://npm.io/package/@types/node.md) ^7.10.9
- [@types/consola](https://npm.io/package/@types/consola.md) ^2.2.5
- [md5-typescript](https://npm.io/package/md5-typescript.md) ^1.0.5
- [gulp-typescript](https://npm.io/package/gulp-typescript.md) ^6.0.0-alpha.1
- [@types/js-base64](https://npm.io/package/@types/js-base64.md) ^2.3.1
- [@types/gulp-watch](https://npm.io/package/@types/gulp-watch.md) ^4.1.34

## Recent versions

- 1.3.9 (latest) — 2020-09-17
- 1.3.81 — 2020-05-04
- 1.3.8 — 2020-05-03
- 1.3.7 — 2020-05-03
- 1.3.6 — 2020-05-03
- 1.3.5 — 2020-05-03
- 1.3.4 — 2020-05-03
- 1.3.3 — 2020-05-03
- 1.3.2 — 2020-05-03
- 1.3.1 — 2020-05-02
- 1.3.0 — 2020-05-02
- 1.2.1 — 2020-05-02
- 1.1.8 — 2020-04-26
- 1.1.7 — 2020-04-25
- 1.1.6 — 2020-04-25
- … 15 more at https://npm.io/package/cross-tpl/versions

## README

### Cross-tp is a convenient template builder. After configuring and running the script, go out, get the js file you can connect to your project.
#### Using

``` ts
import { CrossTpl }  from 'cross-tpl'

const crossTpl = new CrossTpl({
    dirname: __dirname,
    src: 'view',
    upload: false // If true, then the build function will update the previously created
});

crossTpl.create(); // build a script
crossTpl.upload(); // update the script
crossTpl.build(); // build and update the script
crossTpl.watch(); // for automatic updates. Delete, add, update templates. works on gulp
```

#### Result | source
``` ts 
    // src/dist/CrossTemplates.js || or other specified path in outDir configuration
    /****/

    /*/open/8cd728920dc49356699b7ef285a1323b***/
    /*!*************************************************************!*\
    !*** Name: hi.html ***!
    !*** Template: view/hi.html:52 ***!
    !*** Create:   2020-04-25T08:44:46.325Z ***!
    !*** Modified: 2020-04-25T09:02:28.153Z ***!
    \*************************************************************/
    CrossTplCore.templates.set('8cd728920dc49356699b7ef285a1323b', /**8cd728920dc49356699b7ef285a1323b**/ "PGRpdiBpZD0iY3Jvc3MtdHBsIj5IaSEgTXkgbmFtZSBpcyBDcm9zc0pzIDopIDwvZGl2Pg==" /**-8cd728920dc49356699b7ef285a1323b**/);
    /*/close/8cd728920dc49356699b7ef285a1323b***/

    /****/

    CrossTemplates.render = function (name, handler) {
        if (handler === void 0) { handler = false; }
        if (CrossTplCore.options.dirHash) {
            name = Md5.init(name);
        }
        var content = CrossTplCore.templates.get(name) || '';
        if (CrossTplCore.options.contentBase64 && content) {
            content = decodeURIComponent(atob(content).split('').map(function (c) {
                return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
            }).join(''));
        }
        return content || '';
    };

    /*****/
```
#### Result | use of source
``` ts 
    import { CrossTemplates } from 'cross-tpl/src/dist/CrossTemplates';
    const template = CrossTemplates.render('hi.html');

    console.log(template); // <div id="cross-tpl">Hi! My name is CrossJs :) </div>
```

---
_Source: https://npm.io/package/cross-tpl · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
