forked from cordjs/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
templateLoader.coffee
34 lines (29 loc) · 926 Bytes
/
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
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")
loadTemplate: (path, callback) ->
require ["cord-t!" + path], ->
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 }")