Updated README

This commit is contained in:
Sahat Yalkabov
2014-02-24 08:57:58 -05:00
parent eff0c28b54
commit e513cabd19

View File

@ -343,7 +343,7 @@ Recommended Client-Side libraries
Pro Tips Pro Tips
-------- --------
- When you install a new npm package, add a *--save* flag and it will be automatially - When installing an NPM package, add a *--save* flag, and it will be automatially
added to `package.json` as well. For example, `npm install --save moment`. added to `package.json` as well. For example, `npm install --save moment`.
- Use [async.parallel()](https://github.com/caolan/async#parallel) when you neeed to run multiple - Use [async.parallel()](https://github.com/caolan/async#parallel) when you neeed to run multiple
asynchronous tasks, and then render a page, but only when all tasks are completed. For example, you might asynchronous tasks, and then render a page, but only when all tasks are completed. For example, you might
@ -391,12 +391,15 @@ script(src='/js/application.js')
``` ```
As soon as you start bringing in more JavaScript libraries, the benefits of concatenating and minifying As soon as you start bringing in more JavaScript libraries, the benefits of concatenating and minifying
JavaScript files will be even greater. JavaScript files will be even greater.
Using connect-assets library it's as as simple as: Using **connect-assets** library, it is as as simple as declaring these two lines:
```jade
```
!= css('styles') // expects public/css/styles.less != css('styles') // expects public/css/styles.less
!= js('application') // expects public/js/application.js != js('application') // expects public/js/application.js
``` ```
:bulb: **Tip:** This works because in *connect-assets* middleware we have specified `helperContext: app.locals`.
The only thing you need to remember is to define your JavaScript files inside `public/js/application.js` using this The only thing you need to remember is to define your JavaScript files inside `public/js/application.js` using this
strange syntax notation (Sprockets-style) borrowed from Rails. I know it's an extra thing to learn strange syntax notation (Sprockets-style) borrowed from Rails. I know it's an extra thing to learn
for someone who has never seen Rails asset pipeline before, but in this case, I think benefits outweigh the costs. for someone who has never seen Rails asset pipeline before, but in this case, I think benefits outweigh the costs.