Express Notes App.helpers and App.locals

Source: Internet
Author: User

App.helpers and App.dynamichelpers are express2. X is used by the static/Dynamic view assistant through its registration function,

For example

[JavaScript]View PlainCopyprint?
    1. App.helpers ({
    2. <span style="White-space:pre" > </span>inspect: function (obj) {
    3. <span style="White-space:pre" > </span>return util.inspect (obj, true);
    4. }
    5. });

But after the Express 3.x these two methods were abolished,

3.x is using the

 
    1. App.locals ({
    2. Key2:value1,
    3. Key2:value2
    4. })
 
    1. There are the following:
 
    1. App.locals ({
    2. Inspect: function (obj) {
    3. return Util.inspect (obj, true);
    4. }
    5. });


But it's a big change after express4.x.
app.locals.key1 = value1;app.locals.key2 = value2;
As follows:
 
    1. app.locals.inspect=function (obj) {
    2. return Util.inspect (obj, true);
    3. }

Express Notes App.helpers and App.locals

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.