2017-02-15 2 views
0

ejs include 문 안에 객체를 전달해야합니다. 저도 같은 문제에 대한 몇 가지 질문을 찾았지만 다음과 같은 처리를 할 때 나는 이상한 오류가ejs include 문 안에 객체를 전달하십시오.

<div> 
<%- include (folder/index , {"user": user}) %> 
</div> 

내가 얻을

ENOENT: no such file or directory, open '/views/(folder/index.ejs' 

내가를 통과 할 때 나는 ENOENT을받을 이유는 어떤 생각 인라인 오브젝트?

내가 간단하게 할 경우

<%- include folder/index %> 

작동하지만 난 인덱스에 사용자 개체를 전달해야합니다. 이것을 할 수있는 방법이 있습니까?

답변

1

include 뒤에 공백을 삽입하면 EJS는 include 전 처리기 지시문 (<% include folder/index %>)을 사용합니다.

<div> 
    <%- include('folder/index', {user: user}) %> 
</div> 

( includes Documentation 참조) : 그들은 여전히 ​​지원되지만, 새로운 구문은 다음과 같다
관련 문제