Switched from text/template to html/template

This commit is contained in:
Suraj Patil 2016-12-20 21:42:22 +05:30
parent f34db50464
commit eb45ec612e
6 changed files with 19 additions and 15 deletions

Binary file not shown.

View File

@ -9,6 +9,7 @@ DeleteAll()
import ( import (
"database/sql" "database/sql"
"html/template"
"log" "log"
"strconv" "strconv"
"strings" "strings"
@ -135,7 +136,7 @@ func GetTasks(username, status, category string) (types.Context, error) {
task.CompletedMsg = strconv.Itoa(taskCompleted) + " complete out of " + strconv.Itoa(totalTasks) task.CompletedMsg = strconv.Itoa(taskCompleted) + " complete out of " + strconv.Itoa(totalTasks)
} }
task.Content = string(md.Markdown([]byte(task.Content))) task.ContentHTML = template.HTML(md.Markdown([]byte(task.Content)))
// TaskContent = strings.Replace(TaskContent, "\n", "<br>", -1) // TaskContent = strings.Replace(TaskContent, "\n", "<br>", -1)
if err != nil { if err != nil {
log.Println(err) log.Println(err)

View File

@ -59,7 +59,7 @@
</p> <span class="toggle glyphicon glyphicon-resize-full"></span> </p> <span class="toggle glyphicon glyphicon-resize-full"></span>
<span class="noteContent"> <span class="noteContent">
{{$value.Content}} {{$value.ContentHTML}}
{{$value.CompletedMsg}} {{$value.CompletedMsg}}
<div class="commentslist"> <div class="commentslist">
{{range $value.Comments}} {{range $value.Comments}}

View File

@ -1,5 +1,7 @@
package types package types
import "html/template"
/* /*
Package types is used to store the context struct which Package types is used to store the context struct which
is passed while templates are executed. is passed while templates are executed.
@ -9,6 +11,7 @@ type Task struct {
Id int `json:"id"` Id int `json:"id"`
Title string `json:"title"` Title string `json:"title"`
Content string `json:"content"` Content string `json:"content"`
ContentHTML template.HTML `json:"content_html"`
Created string `json:"created"` Created string `json:"created"`
Priority string `json:"priority"` Priority string `json:"priority"`
Category string `json:"category"` Category string `json:"category"`

View File

@ -5,13 +5,13 @@ Holds the non insert/update/delete related view handlers
*/ */
import ( import (
"html/template"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http" "net/http"
"os" "os"
"strconv" "strconv"
"strings" "strings"
"text/template"
"github.com/thewhitetulip/Tasks/db" "github.com/thewhitetulip/Tasks/db"
"github.com/thewhitetulip/Tasks/sessions" "github.com/thewhitetulip/Tasks/sessions"

View File

@ -3,8 +3,8 @@ package views
/*Holds the fetch related view handlers*/ /*Holds the fetch related view handlers*/
import ( import (
"html/template"
"net/http" "net/http"
"text/template"
"time" "time"
"github.com/thewhitetulip/Tasks/db" "github.com/thewhitetulip/Tasks/db"