Browse Source

Made pathing more platform agnostic as per Brian Ketelsen's feedback.

Wirecog 6 years ago
parent
commit
2d4231bb67
1 changed files with 6 additions and 5 deletions
  1. 6
    5
      uxcog.go

+ 6
- 5
uxcog.go View File

@@ -7,6 +7,8 @@ package cog
7 7
 
8 8
 import (
9 9
 	"errors"
10
+	"os"
11
+	"path/filepath"
10 12
 	"reflect"
11 13
 	"strings"
12 14
 
@@ -34,7 +36,7 @@ type UXCog struct {
34 36
 func (u *UXCog) getCogPrefixName() string {
35 37
 
36 38
 	if u.cogType != nil {
37
-		result := strings.Split(u.cogType.PkgPath(), `/`)
39
+		result := strings.Split(u.cogType.PkgPath(), string(os.PathSeparator))
38 40
 		return "cog:" + result[len(result)-1]
39 41
 	} else {
40 42
 		return ""
@@ -68,7 +70,7 @@ func (u *UXCog) CogInit(ts *isokit.TemplateSet) {
68 70
 	if ts != nil {
69 71
 		u.templateSet = ts
70 72
 	}
71
-	u.cogTemplatePath = DefaultGoSourcePath + "/" + u.cogType.PkgPath() + "/" + DefaultTemplatesDirectoryName
73
+	u.cogTemplatePath = filepath.Join(DefaultGoSourcePath, u.cogType.PkgPath(), DefaultTemplatesDirectoryName)
72 74
 	u.cogPrefixName = u.getCogPrefixName()
73 75
 
74 76
 	if isokit.OperatingEnvironment() == isokit.ServerEnvironment {
@@ -140,8 +142,7 @@ func (u *UXCog) RenderCogTemplate() {
140 142
 
141 143
 	rp := isokit.RenderParams{Data: u.Props, Disposition: isokit.PlacementReplaceInnerContents, Element: *u.element, ShouldPopulateRenderedContent: populateRenderedContent}
142 144
 
143
-	u.templateSet.Render(u.getCogPrefixName()+"/"+strings.Split(u.getCogPrefixName(), ":")[1], &rp)
144
-
145
+	u.templateSet.Render(filepath.Join(u.getCogPrefixName(), strings.Split(u.getCogPrefixName(), ":")[1]), &rp)
145 146
 	if u.hasBeenRendered == false {
146 147
 		u.hasBeenRendered = true
147 148
 
@@ -184,8 +185,8 @@ func (u *UXCog) Render() error {
184 185
 		if VDOMEnabled == true {
185 186
 
186 187
 			rp := isokit.RenderParams{Data: u.Props, Disposition: isokit.PlacementReplaceInnerContents, Element: *u.element, ShouldPopulateRenderedContent: true, ShouldSkipFinalRenderStep: true}
187
-			u.templateSet.Render(u.getCogPrefixName()+"/"+strings.Split(u.getCogPrefixName(), ":")[1], &rp)
188 188
 
189
+			u.templateSet.Render(filepath.Join(u.getCogPrefixName(), strings.Split(u.getCogPrefixName(), ":")[1]), &rp)
189 190
 			D := dom.GetWindow().Document()
190 191
 			cogRoot := D.GetElementByID(u.id).FirstChild().(*dom.HTMLDivElement)
191 192
 			//contents := cogRoot.InnerHTML()