An open API service indexing awesome lists of open source software.

https://github.com/chowa/cwhtml

Small front-end engineering modular development scaffolding
https://github.com/chowa/cwhtml

frontend inline-source layout minifier module sass scaffolding sprite template

Last synced: 6 months ago
JSON representation

Small front-end engineering modular development scaffolding

Awesome Lists containing this project

README

          



# cwhtml

Small front-end engineering modular development scaffolding

[![Build Status](https://travis-ci.org/chowa/cwhtml.svg?branch=master)](https://travis-ci.org/chowa/cwhtml)
[![npm](https://img.shields.io/npm/v/cwhtml.svg)](https://www.npmjs.com/package/cwhtml)
[![npm](https://img.shields.io/npm/dm/cwhtml.svg)](https://www.npmjs.com/package/cwhtml)
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000)](https://opensource.org/licenses/MIT)

## Install

```
npm i cwhtml -g
```

## Usage

### create project

```
cwhtml create
```

### build

```
cwhtml build
```

### development

```
cwhtml dev
```

## Congifure

### File

`.cwhtmlrc`

### Options

## Directory rules

```
cwhtml-project
|
|-- dist
|
|-- src
| |-- component
| | |-- header /* auto import style and js */
| | | |-- index.tpl
| | | |-- index.scss
| | | |-- index.js
| |
| |-- data /* page render data */
| | |-- index.js
| |
| |-- image
| | |-- banner.png
| |
| |-- sprite
| | |-- index
| | | |-- icon.png
| |
| |-- layout
| | |-- common.tpl
| |
| |-- page /* entry */
| | |-- index.tpl
| |
| |-- script
| | |-- index.js
| |
| |-- style
| | |-- index.scss /* free choice css sass less */
| |
| |-- iconfont
| | |-- font.eot
| | |-- font.woff
| | |-- font.woff2
| | |-- font.svg
| |
| |-- favicon.ico
```

## Synatx

### Template inheritance

```
{{extend './layout.tpl'}}
```

### Sub template

***auto include `src/component/header/*`***

```
{{include header}}
```

### Block inheritance

```
{{block content}}

sub conetnt


{{/block}}
```

### Loop

Key and item are keywords

```
{{each from=data}}

  • {{item.name}}

  • {{/each}}
    ```

    ### Condition

    > does not support boolean

    ```
    {{if a=1}}

    true


    #{{else}}

    false


    {{/if}}

    {{if c=case}}

    case


    {{elseif c=which}}

    which


    {{/if}}
    ```

    ### Variable

    ```
    {{set a=1}}

    {{a}}
    ```

    ### Import style

    > support css sass less

    ```
    {{style '../style/index.scss'}}
    ````

    ### Import javascript

    ```
    {{script '../js/index.js'}}
    ````

    ## Options

    ```js
    root: './src',
    output: './dist'
    extname: '.tpl'
    ```