ejs能支持视图的继承吗
发布于 9 年前 作者 wyixin 6729 次浏览 最后一次编辑是 8 年前 来自 问答

例如 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 回复

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

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

谢谢回复。

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

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

回到顶部