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,22 +1,25 @@
package types
import "html/template"
/*
Package types is used to store the context struct which
is passed while templates are executed.
*/
//Task is the struct used to identify tasks
type Task struct {
Id int `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Created string `json:"created"`
Priority string `json:"priority"`
Category string `json:"category"`
Referer string `json:"referer,omitempty"`
Comments []Comment `json:"comments,omitempty"`
IsOverdue bool `json:"isoverdue, omitempty"`
IsHidden int `json:"ishidden, omitempty`
CompletedMsg string `json:"ishidden, omitempty"`
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"`
Referer string `json:"referer,omitempty"`
Comments []Comment `json:"comments,omitempty"`
IsOverdue bool `json:"isoverdue, omitempty"`
IsHidden int `json:"ishidden, omitempty`
CompletedMsg string `json:"ishidden, omitempty"`
}
type Tasks []Task

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"