이 코드로 제대로 렌더링하려면 '독립형'템플릿을 얻을 수는 있지만 템플릿 상속을 사용할 수는 없습니다. 내가 간과하거나 누군가가 알고있는 다른 경고가 있습니까?문제점 Node.js Express 3.x 템플릿 상속을 consolidate.js를 통해 Swig과 함께 작동
오류 : "... /views/index.html"의 3 번 줄에 Circular extends가 있습니다!
app.js :
var express = require('express')
, cons = require('consolidate')
, http = require('http')
var app = express();
app.engine('html', cons.swig);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.set('view options', { layout: false });
app.get('/', function(req, res){
res.render('index.html', { header: 'Express' });
});
http.createServer(app).listen(3000, function(){
console.log("Express server listening on port 3000");
});
index.html을
{% extends 'base.html' %}
{% block content %}<h1>{{ header }}</h1>{% endblock %}
base.html는
<!DOCTYPE html>
<html>
<head>
<title>{% block title %}Express{% endblock %}</title>
</head>
<body>
{% block content %}{% endblock %}
</body>
</html>
그것을했다! 나는 행운이없는 '익스프레스'와 '상속'이라는 용어에 대한 문제를 계속 조사했다. 감사! – Brian