Node.js-EJS-包括部分 [英] Node.js - EJS - including a partial

查看:105
本文介绍了Node.js-EJS-包括部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将嵌入式Javascript渲染器用于节点: https://github.com/visionmedia/ejs

I am trying to use Embedded Javascript renderer for node: https://github.com/visionmedia/ejs

我想知道如何在.ejs视图文件中包括另一个视图文件(部分).

I would like to know how I can include another view file (partial) inside a .ejs view file.

推荐答案

使用Express 3.0:

With Express 3.0:

<%- include myview.ejs %>

路径是相对于包含文件的调用方的,而不是相对于使用app.set("views", "path/to/views")设置的views目录的相对路径.

the path is relative from the caller who includes the file, not from the views directory set with app.set("views", "path/to/views").

EJS包含

(更新:ejs v3.0.1的最新语法为<%- include('myview.ejs') %>)

(Update: the newest syntax for ejs v3.0.1 is <%- include('myview.ejs') %>)

这篇关于Node.js-EJS-包括部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆