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
 
7
 
8
 import (
8
 import (
9
 	"errors"
9
 	"errors"
10
+	"os"
11
+	"path/filepath"
10
 	"reflect"
12
 	"reflect"
11
 	"strings"
13
 	"strings"
12
 
14
 
34
 func (u *UXCog) getCogPrefixName() string {
36
 func (u *UXCog) getCogPrefixName() string {
35
 
37
 
36
 	if u.cogType != nil {
38
 	if u.cogType != nil {
37
-		result := strings.Split(u.cogType.PkgPath(), `/`)
39
+		result := strings.Split(u.cogType.PkgPath(), string(os.PathSeparator))
38
 		return "cog:" + result[len(result)-1]
40
 		return "cog:" + result[len(result)-1]
39
 	} else {
41
 	} else {
40
 		return ""
42
 		return ""
68
 	if ts != nil {
70
 	if ts != nil {
69
 		u.templateSet = ts
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
 	u.cogPrefixName = u.getCogPrefixName()
74
 	u.cogPrefixName = u.getCogPrefixName()
73
 
75
 
74
 	if isokit.OperatingEnvironment() == isokit.ServerEnvironment {
76
 	if isokit.OperatingEnvironment() == isokit.ServerEnvironment {
140
 
142
 
141
 	rp := isokit.RenderParams{Data: u.Props, Disposition: isokit.PlacementReplaceInnerContents, Element: *u.element, ShouldPopulateRenderedContent: populateRenderedContent}
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
 	if u.hasBeenRendered == false {
146
 	if u.hasBeenRendered == false {
146
 		u.hasBeenRendered = true
147
 		u.hasBeenRendered = true
147
 
148
 
184
 		if VDOMEnabled == true {
185
 		if VDOMEnabled == true {
185
 
186
 
186
 			rp := isokit.RenderParams{Data: u.Props, Disposition: isokit.PlacementReplaceInnerContents, Element: *u.element, ShouldPopulateRenderedContent: true, ShouldSkipFinalRenderStep: true}
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
 			D := dom.GetWindow().Document()
190
 			D := dom.GetWindow().Document()
190
 			cogRoot := D.GetElementByID(u.id).FirstChild().(*dom.HTMLDivElement)
191
 			cogRoot := D.GetElementByID(u.id).FirstChild().(*dom.HTMLDivElement)
191
 			//contents := cogRoot.InnerHTML()
192
 			//contents := cogRoot.InnerHTML()