我想通过将位置作为本地发送来选择要包含哪个玉。这是我试过的:
app.js:
var express = require('express');
var fs = require('fs');
var app = express();
var jade = require('jade');
app.get('/jadetest', function(req, res){
var fn = jade.compileFile('views/over.jade');
var locals = {"bodystring": "./body.jade"}
res.writeHead(200, {'Content-Type': 'html'});
res.write(fn(locals));
res.end();
})
var server = app.listen(3000);
over.jade:
doctype html
html(lang="en")
head
title= pageTitle
body
h1 Title
// This doesn't work
//include bodystring
// or this
//include #{bodystring}
// or this
//include -bodystring
// this does, but it doesn't offer the flexibility I want
include ./body.jade
body.jade:
h1 Jade - node template engine
我可以将标题设置为bodystring的内容,但是当我把它放在include中时它不喜欢它。这有单独的语法吗?有可能吗?我是在努力做事吗?