-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.fan
More file actions
45 lines (38 loc) · 1.43 KB
/
Example.fan
File metadata and controls
45 lines (38 loc) · 1.43 KB
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
using afIoc
using afBedSheet
using afDuvet
class Example {
@Inject HtmlInjector? injector
Text duvetExample() {
// inject meta tags and stylesheets into your HTML
injector.injectMeta.withName("author").withContent("Fantom-Factory")
// inject a RequireJS script snippet
// this ensures all dependencies are loaded before execution
injector.injectRequireScript(["jquery":"\$"],
"alert('jQuery v' + \$().jquery);"
)
// let Duvet inject all it needs into a plain HTML shell
return Text.fromHtml(
"<html><head></head><body><h1>Duvet by Alien-Factory</h1></body></html>"
)
}
}
@SubModule { modules=[DuvetModule#] }
const class AppModule {
@Contribute { serviceType=Routes# }
Void contributeRoutes(Configuration conf) {
conf.add(Route(`/`, Example#duvetExample))
}
@Contribute { serviceType=ScriptModules# }
Void contributeScriptModules(Configuration config) {
// configure any non-standard AMD modules
config.add(
ScriptModule("jquery").atUrl(`//code.jquery.com/jquery-2.1.1.min.js`)
)
}
}
class Main {
Int main() {
BedSheetBuilder(AppModule#.qname).startWisp(8080)
}
}