EJS - Как отобразить переменные / переменные не отображаются

Я просто приведу истощение.

Server.js:

// load the things we need
var express = require('express');
var app = express();

// set the view engine to ejs
app.set('view engine', 'ejs');

// use res.render to load up an ejs view file

// index page 
app.get('/', function(req, res) {
    var tagline = "Any code of your own that you haven't looked at for six or more months might as well have been written by someone else";

    res.render('pages/index', {
        tagline: tagline
    });
});

// about page 
app.get('/about', function(req, res) {
    res.render('pages/about');
});

app.listen(8080);
console.log('8080 is the magic port');

И в index.ejs бит, который мне нужно отобразить, находится здесь:

<div class="jumbotron">
  <h1>This is great</h1>
  <h2><%= tagline %></h2>
  <p>Welcome to templating using EJS</p>
</div>

Однако, когда я запускаю эти коды вместе, я получаю всю страницу, <%= tagline %> часть. Это очень раздражает меня, поскольку в настоящее время я не могу использовать переменные EJS. Кто-нибудь может помочь?!

0 ответов

Другие вопросы по тегам