2016-09-21 2 views
1

내 프로젝트에 스텐실이 임베드되었습니다 (Kitura https://github.com/IBM-Swift/Kitura, 템플릿 엔진 스텐실 https://github.com/kylef/Stencil#include). 태그 {% include "comment.html" %}을 사용하는 방법을 모르겠습니다. 예제가 있지만 작동하지 않습니다.태그 {% include example.html %} 사용 방법

example.stencil.html

<html> 
     <head> 
      hello example 
      {% include "include.stencil.html" %} 
     </head> 
</html> 

include.stencil.html

<b>I'm here</b> 

코드 스위프트

import Stencil 

let pathTemp=Path("include.stencil.html") 
let context = Context(dictionary: ["loader": TemplateLoader(paths: [pathTemp])]) 
do { 
    let template = try Template(named: fileName) 
    let rendered = try template.render(context) 
    return rendered 
}catch 
{ 
    return "Error:\(error)" 
} 

Error :Error:'include.stencil.html' template not found in ../include.stencil.html

를 사용하는 방법, PLZ 도와주세요. :)

답변

0

경로에 파일 이름이 포함되어있는 것 같습니다. 경로는 파일 자체의 이름을 제외하고 파일의 위치에 대한 경로 여야합니다.

let pathTemp=Path("/path/to/my/file/") 
관련 문제