2016-09-07 3 views
1

,이 오류가 발생합니다중첩 된 템플릿이 제대로

package controllers 

import "github.com/revel/revel" 

type Mirror struct { 
    *revel.Controller 
} 

func (m Mirror) Index() revel.Result { 
    return m.Render() 
} 

나는 아직도 얻을 : 여기

results.go:232: Template Execution Error (in Mirror/index.html): html/template:Mirror/index.html: "\"" in attribute name: " class\"quote-component\" id=\"quot" 

는 내용입니다 mirror.html의 :

<!-- AUTH STATES --> 
<section class="auth-states"> 

    <!-- FACE DETECTED W/IN RANGE --> 
    {{template "partials/faceClose.html" .}} 

    <!-- USER DETECTED --> 
    {{template "partials/userDetected.html" .}} 

    <!-- NON USER DETECTED --> 
    {{template "partials/nonUserDetected.html" .}} 

    <!-- TIME OUT LOGS USER OUT --> 
    {{template "partials/loggingOut.html" .}} 

</section> 

<div class="clear eyelevel"> 

    <!-- WEATHER--> 
    {{template "partials/weather.html" .}} 

    <!-- TIMELY CONTENT: TIMESTAMP AND ALERTS --> 
    <div class="timely-content"> 

    <!-- TIMESTAMP --> 
    {{template "partials/timestamp.html" .}} 

    <!-- EMOTION --> 
    {{template "partials/emotion.html" .}} 

    </div> 

</div> 
<img id="shot-preview"/> 

<!-- LOW PRIORITY CONTENT --> 
<section class="low-pri-content auth-content"> 

    <h2 class="logged-in-stamp"> 
    Here's the scoop, <span id="logged-in-name"></span>: 
    </h2> 

    {{template "partials/traffic.html" .}} 
    {{template "partials/stocks.html" .}} 
    {{template "partials/newsFeed.html" .}} 


</section> 

<div id="video-hidden" aria-hidden="true"> 
    <video id="cameraPreview" class="cameraPreview"></video> 
</div> 

<script src="https://code.jquery.com/jquery-2.2.1.js"></script> 
<script src="https://cdn.jsdelivr.net/momentjs/2.11.2/moment.min.js"></script> 
<script src="/public/js/weather.js"></script> 
<script src="/public/js/stock.js"></script> 
<script src="/public/js/news.js"></script> 
<script src="/public/js/traffic.js"></script> 
<script src="/public/js/mirror.js"></script> 
<script src="/public/js/authenticate.js"></script> 

응용 프로그램의 구조는 르벨 권장 사항을 다음과 프로젝트 자체는 르벨를 사용하여 이동하는 노드에서 this project 마이그레이션됩니다.

내 질문은 무엇입니까? 그 오류 메시지는 무엇을 의미합니까? 상단 행이 무엇인지에 관계없이 항상 mirror.html 파일의 상단 4 행을로드합니다.

답변

1

오류는하지 mirror.html이 아니라 index.html에 : 일부 요소의 class 속성을 지정할 때 단순히 등호 '='을 왼쪽 예를 들어 당신이 쓴

results.go:232: Template Execution Error (in Mirror/index.html): html/template:Mirror/index.html: "\"" in attribute name: " class\"quote-component\" id=\"quot"

:

<span class"quote-component" id="quot">... 

확인하려면 다음 간단한 예를 참조하십시오.

const templ = `<html><body> 
     <span class"quote-component" id="quot">Bad syntax</span> 
     </body></html>` 

t := template.Must(template.New("").Parse(templ)) 
err := t.Execute(os.Stdout, nil) 
fmt.Println(err) 

출력 : 귀하의 것과 거의 동일합니다 (Go Playground에서 시도하십시오) :

관련 문제