<commit_before># HOGAN-EXPRESS

Mustache template engine for express 3.x. 

Use twitter's [hogan.js](https://github.com/twitter/hogan.js) engine.

Supports
  - partials 
  - layout
  - caching

### Install

`npm install hogan-express`

### Usage

**Setup**:
```
app.set('view engine', 'html')
app.set('layout', 'layout') # rendering by default
app.set('partials', head: "head") # partials using by default on all pages
app.enable('view cache')
app.engine 'html', require('hogan-express')
```
----
**Rendering template**:
```
app.get '/', (req,res)->
  res.locals = what: 'World'
  res.render "index", partials: {temp: 'temp'}
```
(will render `layout.html` with `index.html`, `head.html` and `temp.html` partials)

`{{{ yield }}}` variable in template means the place where your page are rendered inside the layout.

----
**Custom yield tags**:

You can define more extension points in `layout.html` using custom tags ``{{yield-<name>}}``:

layout:

```
<head>
	...
	{{{yield-styles}}}
	{{{yield-scripts}}}
</head>
```
index:

```
{{#yield-styles}}
	<style>
		...
	</style>
{{/yield-styles}}

{{#yield-scripts}}
	<script>
		...
	</script>
{{/yield-scripts}}
```

Page `index.html` will be rendered into ``{{yield}}`` without content of ``{{#yield-styles}}...{{/yield-styles}``
and ``{{#yield-scripts}}...{{/yield-scripts}}``. That content goes into accordingly named tags in `layout.html`.
If ``{{{yield-styles}}}`` is missing, styles tag content will not be rendered.

----
**Custom layout**:


For render page with custom layout, just specify it in options `res.render "admin.html", layout: "admin-layout"`

### License
MIT License<commit_msg>Readme expansion and update<commit_after>## HOGAN-EXPRESS

[Mustache][1] template engine for the [express 3.x][2] web framework.

Uses twitter's [hogan.js][3] engine.

Supports
  - Partials (Allows you to modularize, to move pieces of templates to their own file - think of these as "included" templates)
  - Layouts (Allows you to consolidate common elements of your templates - think of these as "parent" templates)
  - Caching (Makes your app more efficient by reducing unnecessary rendering)

### Install

Install hogan-express using [npm][4]:

`npm install hogan-express`

### Usage

#### Setup
To use hogan-express, map the file extension of your choice to the
hogan-express engine in your app setup.  For example:

```coffeescript
app.set 'view engine', 'html'    # use .html extension for templates
app.set 'layout', 'layout'       # use layout.html as the default layout
app.set 'partials', foo: 'foo'   # define partials available to all pages
app.enable 'view cache'
app.engine 'html', require('hogan-express')
```

#### Rendering a template

Within your app route callback, define `res.locals` and call `res.render`, passing any partials required by your template.  For example:

```coffeescript
app.get '/', (req,res)->
  res.locals = name: 'Andrew'
  res.render 'template', partials: {message: 'message'}
```

This would render the layout (`layout.html`, defined in setup) using the template (`template.html`) and the specified partials (`message.html`).

If `layout.html` contained:

```html
<p>
  <strong>Message Layout</strong>
  {{{ yield }}}
</p>
```

and `template.html` contained:

```html
<em>{{ name }} says {{> message }}</em>
```

and `message.html` contained:

```html
Hello World.
```

the callback would produce:

```html
<p>
  <strong>Message Layout</strong>
  <em>Andrew says Hello World.</em>
</p>
```

The special `{{{ yield }}}` variable in `layout.html` indicates the location in your layout file where your template is rendered.  You can define your layout using `app.set 'layout', ...` or specify it when calling `res.render`.  If a layout is not provided, the template is rendered directly.

#### Custom yield tags

You can define more extension points in `layout.html` using custom tags ``{{yield-<name>}}``.  For example:

layout:

```html
<head>
  ...
  {{{yield-styles}}}
  {{{yield-scripts}}}
  ...
</head>
```

index:

```html
{{#yield-styles}}
  <style>
    ...
  </style>
{{/yield-styles}}

{{#yield-scripts}}
  <script>
    ...
  </script>
{{/yield-scripts}}
```

The page `index.html` will be rendered into ``{{yield}}`` without the content in ``{{#yield-styles}}...{{/yield-styles}`` and ``{{#yield-scripts}}...{{/yield-scripts}}``. That content goes into accordingly named tags in `layout.html`.  If ``{{{yield-styles}}}`` is missing, the styles tag content will not be rendered.

#### Custom layouts

To render a page with custom layout, just specify it in the options: `res.render "admin.html", layout: "admin-layout"`

### License
hogan-express is released under an [MIT License][5].

[1]: http://mustache.github.io/mustache.5.html
[2]: http://expressjs.com/
[3]: https://github.com/twitter/hogan.js
[4]: https://npmjs.org/
[5]: http://opensource.org/licenses/MIT
{'fraction_non_alphanumeric': 0.1757201646090535, 'fraction_numerical': 0.002674897119341564, 'mean_word_length': 4.160297239915074, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 32, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6827234', 'n_tokens_mistral': 1607, 'n_tokens_neox': 1524, 'n_words': 529}