# shpnode

> Simple Hypertext Preprocessor

Latest version **0.1.12** (published 2018-01-05) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.12 |
| Published | 2018-01-05 |
| First published | 2017-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| Author | maijz |
| Maintainers | maijz |

## Links

- npm: https://www.npmjs.com/package/shpnode
- Repository: https://github.com/maijz128/shpnode
- Homepage: https://github.com/maijz128/shpnode#readme
- Issues: https://github.com/maijz128/shpnode/issues
- npm.io page: https://npm.io/package/shpnode

## Dependencies (4)

- [marked](https://npm.io/package/marked.md) ^0.3.9
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.2
- [chokidar](https://npm.io/package/chokidar.md) ^1.7.0
- [markdown](https://npm.io/package/markdown.md) ^0.5.0

## Recent versions

- 0.1.12 (latest) — 2018-01-05
- 0.1.11 — 2017-11-20
- 0.1.10 — 2017-11-17
- 0.1.9 — 2017-11-17
- 0.1.8 — 2017-11-17
- 0.1.7 — 2017-11-16
- 0.1.6 — 2017-11-16
- 0.1.5 — 2017-11-16
- 0.1.4 — 2017-11-15
- 0.1.3 — 2017-11-15
- 0.1.2 — 2017-11-15
- 0.1.1 — 2017-11-14
- 0.1.0 — 2017-11-14

## README

# shpnode

A Simple Hypertext Preprocessor.

[![experimental](http://badges.github.io/stability-badges/dist/experimental.svg)](http://github.com/badges/stability-badges)
[![Build Status](https://travis-ci.org/maijz128/shpnode.svg?branch=master)](https://travis-ci.org/maijz128/shpnode)
[![NPM](https://img.shields.io/npm/v/marko.svg)](https://www.npmjs.com/package/shpnode)
[![MIT Licence](https://badges.frapsoft.com/os/mit/mit.svg?v=103)](https://opensource.org/licenses/mit-license.php)  

## Introduction

SHP: Simple Hypertext Preprocessor

SHP : 简单超文本预处理器



```javascript
const Shpnode = require('shpnode')

shpnode.newFile('/header.html', '<div>header content</div>')
shpnode.newFile('/index.shp', '<html><shp include="/header.html"></shp><html>')

const html = shpnode.buildFileToHtml('/index.shp')
console.log(html)
// <html><div>header content</div></html>
```



## Install

**npm**:

```shell
npm install shpnode --save
```



## Usage

Filename: `/srcDir/index.shp`:

```html
<html><head></head>
  <body><shp include=""></shp></body>
</html>
```

Filename: `/srcDir/template/header.html`

```html
<div><h1>Header</h1></div>
```

Filename: `/build.js`

```javascript
const Shpnode = require('shpnode');
var shpnode = new Shpnode({
    srcDir: '/srcDir/',
    outDir : '/outDir/',
    resource: ['/template/']
});
shpnode.build();
```

Build:

```shell
# node build.js
```

Output file: `/outDir/index.html`

```html
<html><head></head>
  <body><div><h1>Header</h1></div></body>
</html>
```





## API



###### .build()

Build all files under the `srcDir`  folder and Output  to the `outDir` folder.

```javascript
shpnode.build()	
```



###### .newFile(filePath, fileContent)

```javascript
shpnode.newFile('/header.html', '<div>header content</div>')
shpnode.newFile('/index.shp', '<html><shp include="/header.html"></shp><html>')
```



###### .hasFile(filePath)

```javascript
shpnode.hasFile('/index.shp')	// result: true
```



###### .getFileCount()

```javascript
shpnode.getFileCount()		// result: 2. index.shp and header.html
```



###### .buildFileToHtml(filePath)

```javascript
shpnode.buildFileToHtml('/index.shp')	
// result: <html><div>header content</div></html>
```



###### .buildFIle(filePath)

```javascript
shpnode.buildFile('/index.shp')
```



###### .buildAllFile()

```javascript
shpnode.buildAllFile()		
```



###### .outputFile(filePath)

```javascript
shpnode.outputFile('/index.shp')
/*
  filename `/outDir/index.index`:
  <html><div>header content</div></html>
 */
```



###### .outputAllFile()

```
shpnode.outputAllFile()
```





## License

MIT

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