Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bind i18n in express #79

Closed
crystalwm opened this issue Nov 2, 2015 · 1 comment
Closed

bind i18n in express #79

crystalwm opened this issue Nov 2, 2015 · 1 comment

Comments

@crystalwm
Copy link

when we bind i18n in express
we can use __() method in our swig template.

why we could use __() methdod in our swig template ?

I have seen the i18n source code ,but I still can't figure these problem out?

@crystalwm
Copy link
Author

在res对象上有一个locals属性,只要把方法写入到这个属性,就可以使用了。

app.use(function(req, res, next) {
    res.locals.time1=function(){
        return new Date();
    }
    next();
});

在swig模板中

<h1>{{ time1() }}</h1>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant