# cjsmc

> Compiling mustache templates into a CommonJS Module

Latest version **1.1.1** (published 2016-04-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install cjsmc
pnpm add cjsmc
yarn add cjsmc
bun add cjsmc
```

## 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.1.1 |
| Published | 2016-04-03 |
| First published | 2016-03-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Craig Taub |
| Maintainers | craigtaub |

## Links

- npm: https://www.npmjs.com/package/cjsmc
- Repository: https://github.com/craigtaub/cjsmc
- Homepage: http://github.com/craigtaub/cjsmc
- Issues: https://github.com/craigtaub/cjsmc/issues
- npm.io page: https://npm.io/package/cjsmc

## Recent versions

- 1.1.1 (latest) — 2016-04-03
- 1.1.0 — 2016-04-02
- 1.0.4 — 2016-04-01
- 1.0.3 — 2016-03-30
- 1.0.2 — 2016-03-28
- 1.0.1 — 2016-03-28
- 1.0.0 — 2016-03-28

## README

# CJS Mustache Compiler [![npm version](https://badge.fury.io/js/cjsmc.svg)](https://badge.fury.io/js/cjsmc) [![Build Status](https://travis-ci.org/craigtaub/cjsmc.svg?branch=master)](https://travis-ci.org/craigtaub/cjsmc)

Simple solution for compiling Mustache templates into a CommonJS Module.
Now available as a 'gulp-plugin' at https://www.npmjs.com/package/gulp-cjsmc.

Example APP using it located https://github.com/craigtaub/cjsmc-example-app.

# Why?
To share same templates on server-side and client-side. Easily added to any bundle.

# How?
Builds them into pre-compiled templates. Accessible via keys as filename.

# Architecture requirements:
    views/

# Usage:

# Build templates

via Gulp (shell):

    gulp.task('clean', function() {
        return del(['client/templates.js']);
    });

    gulp.task('templates', ['clean'], function (cb) {
        return gulp.src('.')
            .pipe(shell([
                'node node_modules/cjsmc/lib/index.js >> client/templates.js'
            ]));
    });

OR gulp-plugin at https://www.npmjs.com/package/gulp-cjsmc

via NPM script:

    'node node_modules/cjsmc/lib/index.js >> client/templates.js'

# Use templates (from anywhere)

    var templates from './client/templates';

    var template = templates['first.mustache'];
    var viewData = { name: 'Your name' };

    var partialTemplate = templates['two.mustache'];
    var partial = { 'partials/two': partialTemplate }

    var markup = Mustache.render(
        template, viewData, partial
    );

# Run tests and linter

    npm run test
    npm run lint

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