2013-10-15 4 views
2

NodeJS 및 백본을 사용하여 핸들 막대 템플릿을 렌더링하려하고 있습니다.핸들 모음 내부의 핸들 막대 템플릿

지금까지 내가 한 일을 완벽하게 작동 할 때 HTML 파일 내부 : HTML 내부

app.MyView = Backbone.View.extend({ 
...  
render: function() {   
    var template = Handlebars.compile($("#my-template").html());   
    this.$el.html(template(this.model.toJSON())); 
    return this; 
} 
... 
}); 

보기 :

<script type="text/x-handlebars-template" id="my-template"> 
    {{text}} 
</script> 

그러나, 나는 핸들 바 템플릿 내에서이 뷰를 배치하는 경우, 그것을 {{text}}이 NodeJS Handlebars 컴파일러에 의해 해석되기 때문에 작동하지 않습니다. 헬퍼를 사용하지 않고이 일을 어떤 방법이 있나요

<script type="text/x-handlebars-template" id="my-template"> 
    {{{braces 'text'}}} 
</script> 

을 :

... 
exports.braces = function(obj1){ 
    return '{{'+param+'}}'; 
} 
... 

그리고 사용 :

답변

0

나는 "중괄호"라는 이름의 도우미를 사용하여 문제를 해결 한?

+0

vkurchatkin의 솔루션은 조금 더 쉽다) 나 (nodejs + 핸들)에 대한 –

+0

그냥 .. 일. – user435943

+0

express-hbs 패키지를 사용하여 Express.js를 사용하여 Node.js와 함께 나를 위해 일했습니다. –

5

시도 :

<script type="text/x-handlebars-template" id="my-template"> 
    \{{text}} 
</script> 
관련 문제