Skip to content

Commit ffaed56

Browse files
committed
template engine description
1 parent 85502c1 commit ffaed56

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

demo/readme.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ Open <a href="http://localhost:3000/" target="_blank">http://localhost:3000/</a>
2121

2222
In short [CSS Modules](https://github.com/css-modules/css-modules) provide modularity with generated class names. Therefore, generated names should be present in CSS styles and in templates which form resulting html. Since, we talk about server rendering in the current example I'll show you how to set require hook to generate the same names in runtime as the CSS styles.
2323

24+
2425
### Frontend
2526

2627
The modern frontend is so tough that you have to use particular bundler systems in order to generate a simple CSS file. My favourite one is [webpack](https://webpack.github.io/), so I'll show you how to set it with the require hook.
2728

29+
2830
### Backend
2931

3032
I use [express](http://expressjs.com/) to handle user requests and [react](https://facebook.github.io/react/) components to serve html for them. In order to make it independent and good looking I decided to use a custom [template engine](http://expressjs.com/en/advanced/developing-template-engines.html) to isolate all the rendering stuff and to have neat calls in the middlewares. So, here is my structure:
3133

32-
- **app/**
34+
- *app/*
3335
- `view-engine.js`
3436
- `worker.js`
3537

@@ -49,3 +51,13 @@ and declares basic middlewares:
4951
```javascript
5052
app.get('/', (req, res) => res.render('Page'));
5153
```
54+
55+
#### `view-engine.js`
56+
57+
Describes the simple [template engine](http://expressjs.com/en/advanced/developing-template-engines.html) and attaches require hook:
58+
59+
```javascript
60+
// teaches node.js to load css files
61+
// uses external config cmrh.conf.js
62+
require('css-modules-require-hook/preset');
63+
```

0 commit comments

Comments
 (0)