Nodejs express4.x Study Notes

Source: Internet
Author: User

Life is endless, tossing and turning

Recently played Nodejs, began to use the Byvoid "Nodejs Development Guide" this book, but Nodejs change too fast, the following blog example to get to the database that one always do not, alas, people stupid should read more, so decided to abandon his process, and start again.

Version of WebStorm11.0 (trial 30 days) for editors. It is a web artifact that can be generated directly. Can be run directly, no need to go to cmd, supervisor./bin/www, it's so convenient for me to be such a lazy man. There are wood. Of course, you have to nodejs the environment first, no longer repeat.

Because before I heard that the jade template is better than the Ejs template, so holding a try to choose the mentality of jade template, although Ejs more close to HTML, easy to get started (this is something), but who call me love toss it.

Well, we're starting to learn jade again. So Baidu to: http://jade-lang.com/reference/iteration/, HTTP://SEGMENTFAULT.COM/A/1190000000357534#ARTICLEHEADER20

You can learn by referring to the two places above. Although the beginning of the translation of a few pieces of HTML, are right, but this is too troublesome, so lazy people began to think of ways: http://www.html2jade.org/directly to the HTML translated into Jade, according to learn the byviod of the Great God of the textbook, and online about 4.x knowledge, can refer to this http://blog.fens.me/nodejs-express4/, probably got a shell.

All right, this is it.

Say a question: just the template

This part, the beginning of writing with Jade, found that click Login or registration, and did not become gray, so you can layout.jade inside the corresponding place to insert, yes, 4.x is a Layout.jade file,

1           inch {'/': ' Home ', '/login ': ' Log in ', '/register ': ' Register '} 2               if Originalurl = = Index3                li.active4                   A (href = index) =  Val5               else6                li7                   A (href = index) =val            
Originalurl variable is the corresponding click on the first page, login, registration of the route address, you can in the corresponding JS file to pass this parameter, I began to want to pass in Req.originalurl, or Req.url or Req.baseurl did not succeed, and then directly use the address of the string constant instead of the

  

Nodejs express4.x Study Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.