Skip to content

Commit e1013e1

Browse files
author
Giulio Grillanda
committed
update docs for baseLayoutName and template engine configuration
1 parent 707c684 commit e1013e1

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

_app/config.md

+65
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The options that can be passed into the Rendr App object.
1515
- **notFoundHandler** _optional_ Callback for [Express.js not found errors](http://expressjs.com/guide/error-handling.html)
1616
- **viewEngine** _optional_ Set a custom [Express.js ViewEngine](http://expressjs.com/api.html#app.engine)
1717
- **viewsPath** _optional_ Override where the views are stored. This path is relative to `entryPath`. Default value is: `app/views`
18+
- **baseLayoutName** _optional_ Set a custom name for the base template file of the app. For example `myLayout`. The default value is set to `__layout`.
1819

1920
Example configuration:
2021

@@ -39,3 +40,67 @@ var config = {
3940

4041
rendr.createServer(config);
4142
```
43+
44+
### Template Adapters
45+
46+
Provides a way for Rendr to utilize custom html template engines (see also Template Engines section below). Rendr's [ViewEngine](https://github.com/rendrjs/rendr/blob/master/server/viewEngine.js) will delegate to the [Template Adapter](https://github.com/rendrjs/rendr-handlebars/blob/master/index.js). You can build your own to provide your template engine of choice (i.e. Jade, Underscore templates, etc).
47+
48+
####Available Template Adapters
49+
50+
- [rendr-handlebars](https://github.com/rendrjs/rendr-handlebars) - [Handlebars.js](https://github.com/wycats/handlebars.js) support. This is the default adapter.
51+
52+
- [rendr-emblem](https://github.com/modalstudios/rendr-emblem) - [Emblem.js](https://github.com/machty/emblem.js/) with [Handlebars.js](https://github.com/wycats/handlebars.js) fallback support.
53+
54+
55+
####Using Custom Adapters
56+
57+
You can tell Rendr which Template Adapter to use. This represents the node-module that contains the adapter.
58+
59+
```js
60+
// /app/app.js
61+
62+
module.exports = BaseApp.extend({
63+
defaults: {
64+
templateAdapter: 'rendr-emblem'
65+
}
66+
67+
});
68+
69+
```
70+
71+
### Template Engines
72+
73+
While Template Adapters provide the layer of abstraction that allow you to use your favorite template engine in a Rendr app, the Template Engine option itself will tell the app which version to use exactly.
74+
The default is set to be Handlebars, which is currently supported by the Rendr-handlebars adapter until version 2.0.0.
75+
**When setting up your Rendr app, you'll need to add your Template Engine of choice to package.json.**
76+
77+
E.g.
78+
79+
```js
80+
// /package.json
81+
82+
"dependencies": {
83+
...
84+
"express": "^4.12.0",
85+
"handlebars": "^2.0.0"
86+
"qs2": "~0.6.6",
87+
...
88+
},
89+
90+
```
91+
92+
####Using Custom Template Engines
93+
94+
You can tell Rendr which Template Engine to use. This represents the node-module that contains the engine.
95+
96+
```js
97+
// /app/app.js
98+
99+
module.exports = BaseApp.extend({
100+
defaults: {
101+
templateEngine: 'handlebars'
102+
}
103+
104+
});
105+
106+
```

app/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ title: App - RendrJS
88
The App is a specialized [Model](/model). A lot of the choices between client / server happen in the app. Here are some of its major features:
99

1010
- Defines the template adapter
11+
- Defines the template engine
1112
- Initializes the client / server [router](/router)
1213
- Initializes the [fetcher](/fetcher)
1314
- Initializes [modelUtils](/model-utils)

0 commit comments

Comments
 (0)