문제

I am currently using static pages (will move over to Jade soon) and I want to pass some information into my index.html when the first request is made.

I know this is possible with jade and I wanted to know what my options are if I use a static page?

For example, I need something like this:

 app.get('/', function(req, res) {
    res.render(config.rootPath + '/public/index.html', {data: 'usernamehere'});
});

and in my index.html I have a script tag:

<script>
    var currentUser = data; <-- I know this will never work...
</script>

So should I make a call from my script tag to get the information or is there another way?

도움이 되었습니까?

해결책

Did you consider express-expose?

"Expose helpers and local variables to the client-side." See the repo.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top