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 (
"database/sql"
"html/template"
"log"
"strconv"
"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.Content = string(md.Markdown([]byte(task.Content)))
task.ContentHTML = template.HTML(md.Markdown([]byte(task.Content)))
// TaskContent = strings.Replace(TaskContent, "\n", "<br>", -1)
if err != nil {
log.Println(err)

View File

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

View File

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

View File

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

View File

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