-
Notifications
You must be signed in to change notification settings - Fork 1
/
coursonnet.libsonnet
110 lines (89 loc) · 1.95 KB
/
coursonnet.libsonnet
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{
local root = self,
page: {
new(filename, title, content): {
local this = self,
filename: filename,
title: title,
content: content,
render: {
[filename]: |||
# %(title)s
%(content)s
||| % this,
},
},
},
lesson: {
new(
slug,
title,
summary,
objectives,
lesson,
conclusion,
): {
content: |||
%(summary)s
## Objectives
%(objectives)s
## Lesson
%(lesson)s
## Conclusion
%(conclusion)s
||| % {
title: title,
summary: summary,
objectives:
std.join('\n', [
'- %s' % objective
for objective in objectives
]),
lesson: lesson,
conclusion: conclusion,
},
slug: slug,
title: title,
filename: self.page.filename,
render: self.page.render[self.filename],
page: root.page.new(
slug + '.md',
title,
self.content,
),
},
},
example: {
new(filename, string, jsonnet={}, type='jsonnet'): {
local this = self,
filename: filename,
string: string,
jsonnet: jsonnet,
type: type,
base64: std.base64(self.string),
playground: 'https://jsonnet-libs.github.io/playground/?code=%s' % self.base64,
code:
|||
~~~%(type)s
%(string)s
// %(filename)s
~~~
||| % self,
render: self.code,
},
withLink():: {
render+:
'<small>[Try `%(filename)s` in Jsonnet Playground](%(playground)s)</small>' % self,
},
withFoldedIframe():: {
iframe: '<iframe src="%s" width="100%%" height="500px"></iframe>' % self.playground,
render+:
|||
<details>
<summary><small>Try in Jsonnet Playground</small></summary>
%(iframe)s
</details>
||| % self,
},
},
}