ejs能支持视图的继承吗
 发布于 11 年前  作者 wyixin  7353 次预览  最后一次回复是 9 年前  来自 问答 

例如 layout.ejs

<html>
	<head>
 	<link href="css/bootstrap.min.css" rel="stylesheet">
	<- This is palcehode for extra css file >
	</head>
	<body>
 		<%- body %>
	</body>
</html>

index.ejs

<extra_css_start>
<link href="css/index.css" rel="stylesheet">
<extra_css_end>
<h1>This Is Index File</h1>

我像问有没有法子把 index.ejs 中的css/index.css替换到 layout.ejs 的 css placehodler 去?

4 回复
allxk

<%include header%> <h1>内容</h1> <%include footer%>

wyixin

这么做是不行的, 我需要填充的是 <- This is palcehode for extra css file > 部分。

谢谢回复。

lcyangily

ejs 没用过,不过Handlebars 轻松解决这个问题,无限层继承

XXonline

@lcyangily Handlebars 怎么继承呀?求大神告诉我下