# gulp-tpl2amd

> Convert js templates to AMD modules no matter what syntax

Latest version **1.0.1** (published 2014-12-16) · 0 weekly downloads

## Install

```sh
npm install gulp-tpl2amd
pnpm add gulp-tpl2amd
yarn add gulp-tpl2amd
bun add gulp-tpl2amd
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2014-12-16 |
| First published | 2014-12-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dexteryy |
| Maintainers | dexteryy |
| Keywords | gulpplugin, amd, template |

## Links

- npm: https://www.npmjs.com/package/gulp-tpl2amd
- Repository: https://github.com/dexteryy/gulp-tpl2amd
- Issues: https://github.com/dexteryy/gulp-tpl2amd/issues
- npm.io page: https://npm.io/package/gulp-tpl2amd

## Dependencies (2)

- [through2](https://npm.io/package/through2.md) ^0.6.3
- [gulp-util](https://npm.io/package/gulp-util.md) ^3.0.1

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2014-12-16

## README

# gulp-tpl2amd

Convert js templates to AMD modules no matter what syntax

## Install

```sh
$ npm install --save-dev gulp-tpl2amd
```

## Usage

```
▸ bower_components/
▾ js/
  ▸ myapp/
    ▾ tpl/ # generated by gulp-tpl2amd
      header.js
    app.js
  ▸ vendor/
    main.js
▸ scss/
▾ tpl/
  ▾ myapp/
      header.tpl
gulpfile.js
```

gulpfile.js

```js
var gulp = require('gulp');
var tpl2amd = require('gulp-tpl2amd');

gulp.task('build:tpl', ['clean:tpl'], function() {
    gulp.src('tpl/myapp/**/*.tpl')
        .pipe(tpl2amd())
        .pipe(gulp.dest('js/myapp/tpl'));
});
```

js/myapp/app.js

```js
define(['tpl/header'], function(tpl_header){
    console.log(tpl_header.template);
});

```

tpl/myapp/header.tpl

```html
<div class="header">
    <h1>{%= title %}</h1>
</div>
```

js/myapp/tpl/header.js

```js
define([], function(){
    return {"template":"\n<div class=\"header\">\n    <h1>{%= title %}</h1>\n</div>\n"}; 
});
```

## License

MIT © [dexteryy](http://github.com/dexteryy)

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