2015-01-05 3 views
1

Mustache/Hogan.js에서 partials/template 상속을 정말로 이해하지 못합니다. herehere으로 정의 했으므로이 작업을 수행하려면 두 개의 다른 파일이 있어야합니다. 돕는턱수염에서 부분/템플릿 상속은 어떻게 작동합니까?

<template id="server-template"> {{#servers}} <b>some html and {{> some other which I dont understand how to use}}</b> {{/servers}} </template> <template id="room-template"> I want this in up there. (in the "partials" tag) </template>

감사 : 내 (클라이언트 측) 페이지에서 다음과 같이 나는 그것을 사용합니다. 나는이 그들을 컴파일 :

var source = $('#room-template').html(), compiled = Hogan.compile(source) $('#main').html(compiled.render(data))

는 그게 가능합니까? 당신이 별도로 파셜를 컴파일하고 render 기능에 전달해야

답변

0

docs 상태 :

파셜의 객체가 Mustache.render 세 번째 인수로 전달 될 수 mustache.js에서

. 객체는 부분적으로 의 이름으로 키잉되어야하며 그 값은 부분 텍스트 여야합니다.

var roomTemplateSource = $('#room-template').html(); 
var roomTemplate = Mustache.compile(roomTemplateSource); 
Mustache.render(template, view, { 
    room: roomTemplate 
}); 

<template id="server-template"> 
     {{#servers}} 
     <b>some html and {{> room}}</b> 
     {{/servers}} 
</template> 
+1

대단히 감사합니다. :) – kurtextrem

관련 문제