-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.libsonnet
More file actions
95 lines (95 loc) · 4.41 KB
/
main.libsonnet
File metadata and controls
95 lines (95 loc) · 4.41 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
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
// DO NOT EDIT: generated by generator/generate.jsonnet
local schema = import './schema.libsonnet';
{
'#': {
filename: 'main.libsonnet',
help: "Jsonnet library to generate XML/HTML.\n## Install\n\n```\njb install github.com/Duologic/jsonml-libsonnet@main\n```\n\n## Usage\n\n```jsonnet\nlocal ml = import 'github.com/Duologic/jsonml-libsonnet/main.libsonnet';\n\nlocal head = ml.tag.new('head');\n\nlocal body =\n ml.tag.new('body')\n + ml.tag.withElements(\n ml.tag.new('h1')\n + ml.tag.withElements(\n ml.literal.new('title')\n )\n );\n\nlocal html =\n ml.tag.new('html')\n + ml.tag.withAttributes(\n ml.attribute.new('lang', 'en')\n )\n + ml.tag.withElements([\n head,\n body,\n ]);\n\n\nhtml.manifest()\n\n```\n",
'import': 'github.com/Duologic/jsonml-libsonnet/main.libsonnet',
installTemplate: '\n## Install\n\n```\njb install %(url)s@%(version)s\n```\n',
name: 'jsonml-libsonnet',
url: 'github.com/Duologic/jsonml-libsonnet',
usageTemplate: "\n## Usage\n\n```jsonnet\nlocal ml = import '%(import)s';\n\nlocal head = ml.tag.new('head');\n\nlocal body =\n ml.tag.new('body')\n + ml.tag.withElements(\n ml.tag.new('h1')\n + ml.tag.withElements(\n ml.literal.new('title')\n )\n );\n\nlocal html =\n ml.tag.new('html')\n + ml.tag.withAttributes(\n ml.attribute.new('lang', 'en')\n )\n + ml.tag.withElements([\n head,\n body,\n ]);\n\n\nhtml.manifest()\n\n```\n",
version: 'main',
},
attribute+:
{
'#new': { 'function': { args: [{ default: null, enums: null, name: 'name', type: 'string' }, { default: null, enums: null, name: 'value', type: ['string', 'number', 'boolean', 'null'] }], help: '' } },
new(name, value):
self.withType()
+ self.withName(name)
+ self.withValue(value),
'#withName': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['string'] }], help: '' } },
withName(value): {
name: value,
},
'#withType': { 'function': { args: [], help: '' } },
withType(): {
type: 'attribute',
},
'#withValue': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['string', 'number', 'boolean', 'null'] }], help: '' } },
withValue(value): {
value: value,
},
},
literal+:
{
'#new': { 'function': { args: [{ default: null, enums: null, name: 'value', type: 'string' }], help: '' } },
new(value):
self.withType()
+ self.withValue(value),
'#withType': { 'function': { args: [], help: '' } },
withType(): {
type: 'literal',
},
'#withValue': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['string'] }], help: '' } },
withValue(value): {
value: value,
},
},
tag+:
{
'#new': { 'function': { args: [{ default: null, enums: null, name: 'name', type: 'string' }], help: '' } },
new(name):
self.withType()
+ self.withName(name)
+ {
manifest():: std.manifestXmlJsonml(schema['$defs'].tag.toJsonML(self)),
},
'#withAttributes': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['array'] }], help: '' } },
withAttributes(value): {
attributes:
(if std.isArray(value)
then value
else [value]),
},
'#withAttributesMixin': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['array'] }], help: '' } },
withAttributesMixin(value): {
attributes+:
(if std.isArray(value)
then value
else [value]),
},
'#withElements': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['array'] }], help: '' } },
withElements(value): {
elements:
(if std.isArray(value)
then value
else [value]),
},
'#withElementsMixin': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['array'] }], help: '' } },
withElementsMixin(value): {
elements+:
(if std.isArray(value)
then value
else [value]),
},
'#withName': { 'function': { args: [{ default: null, enums: null, name: 'value', type: ['string'] }], help: '' } },
withName(value): {
name: value,
},
'#withType': { 'function': { args: [], help: '' } },
withType(): {
type: 'tag',
},
},
}