text-template to html-template

This commit is contained in:
Suraj Patil 2016-12-20 22:03:29 +05:30
parent eb45ec612e
commit 0422eaed3b
4 changed files with 12 additions and 7 deletions

View File

@ -4,7 +4,7 @@
{{ if .Tasks}} {{range $key, $value := .Tasks}} {{ if .Tasks}} {{range $key, $value := .Tasks}}
<div class="note"> <div class="note">
<p class="noteHeading">{{$value.Title}}</p> <span class="toggle glyphicon glyphicon-resize-full"></span> <p class="noteHeading">{{$value.Title}}</p> <span class="toggle glyphicon glyphicon-resize-full"></span>
<span class="noteContent">{{$value.Content}}</span> <span class="noteContent">{{$value.ContentHTML}}</span>
<span class="notefooter"> <span class="notefooter">
<ul class="menu"> <ul class="menu">
<li role="presentation">Priority: {{$value.Priority}}</li> <li role="presentation">Priority: {{$value.Priority}}</li>
@ -36,4 +36,4 @@
</body> </body>
</html> </html>

View File

@ -39,8 +39,8 @@
</div> </div>
{{end}} {{end}}
</div> </div>
{{template "footer.html"}} {{template "_footer.html"}}
</body> </body>
</html> </html>

View File

@ -6,7 +6,7 @@
<p class="noteHeading">{{ $value.Title}}{{if $value.IsOverdue}}<span class="overdue">Overdue</span>{{end}}</p> <span class="toggle glyphicon glyphicon-resize-full"></span> <p class="noteHeading">{{ $value.Title}}{{if $value.IsOverdue}}<span class="overdue">Overdue</span>{{end}}</p> <span class="toggle glyphicon glyphicon-resize-full"></span>
<span class="noteContent"> <span class="noteContent">
{{$value.Content}} {{$value.ContentHTML}}
<div class="commentslist"> <div class="commentslist">
{{range $value.Comments}} {{range $value.Comments}}
<div class="comment"> <div class="comment">
@ -69,4 +69,4 @@
</body> </body>
</html> </html>

View File

@ -4,6 +4,7 @@ package views
import ( import (
"html/template" "html/template"
"log"
"net/http" "net/http"
"time" "time"
@ -28,6 +29,7 @@ func ShowAllTasksFunc(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" { if r.Method == "GET" {
username := sessions.GetCurrentUserName(r) username := sessions.GetCurrentUserName(r)
context, err := db.GetTasks(username, "pending", "") context, err := db.GetTasks(username, "pending", "")
log.Println(context)
categories := db.GetCategories(username) categories := db.GetCategories(username)
if err != nil { if err != nil {
http.Redirect(w, r, "/", http.StatusInternalServerError) http.Redirect(w, r, "/", http.StatusInternalServerError)
@ -60,7 +62,10 @@ func ShowTrashTaskFunc(w http.ResponseWriter, r *http.Request) {
context.Message = message context.Message = message
message = "" message = ""
} }
deletedTemplate.Execute(w, context) err = deletedTemplate.Execute(w, context)
if err != nil {
log.Fatal(err)
}
} }
} }