-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtemplateLoader.coffee
54 lines (47 loc) · 1.53 KB
/
templateLoader.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
define [
'cord-w'
'dustjs-helpers'
'cord!requirejs/pathConfig'
'cord!utils/Future'
], (cord, dust, pathConfig, Future) ->
loadWidgetTemplate: (path) ->
###
Loads widget's template source into dust. Returns a Future which is completed when template is loaded.
@return Future()
###
if dust.cache[path]?
Future.resolved()
else
info = cord.getFullInfo(path)
Future.require("#{ pathConfig.bundles }/#{ info.relativeDirPath }/#{ info.dirName }.html")
loadAdditionalTemplate: (path, templateName) ->
###
Loads additional widget template
@params String path - widgets full path
@params String templatename - additional template file name without any extansions
@return Future() resolves when template is loaded
###
info = cord.getFullInfo(path)
if dust.cache["cord!/#{ info.relativeDirPath }/#{ templateName }"]
Future.resolved()
else
Future.require("cord!/#{ info.relativeDirPath }/#{ templateName }.html")
loadTemplate: (path, callback) ->
###
dustjs.onLoad handler
###
if path.indexOf('!') == -1
fullPath = "cord-t!" + path
else
fullPath = path + '.html'
require [fullPath], callback
loadToDust: (path) ->
###
Loads compiled dust template from the given path into the dust cache.
Path is considered as relative to 'bundles' root, but must begin with slash (/).
@return Future()
###
if dust.cache[path]?
Future.resolved()
else
Future.require("#{ pathConfig.bundles }/#{ path }")