-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvelocity-snippets-vscode.vtl
132 lines (120 loc) · 4.23 KB
/
velocity-snippets-vscode.vtl
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{
// Place your snippets for Velocity here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"dotcms: $dotcontent pull": {
"prefix": "dcquery",
"body": [
"#set (\\$$1 = {",
"\t'query': [",
"\t\t\"+contentType:$2\",",
"\t\t\"+${2:label}.$3:$0\",",
"\t\t\"\\$!{QHOST}\"",
"\t],",
"\t'limit': 0,",
"\t'sort': \"modDate desc\",",
"\t'results': \\$__null",
"})",
"#set (\\$${1:label}.results = \\$dotcontent.pull(\\$UtilMethods.join(\\$${1:label}.query, ' '), \\$${1:label}.limit, \\$${1:label}.sort))"
],
"description": "Create structured $dotcontent.pull()"
},
"dotcms: $dotcontent.pull() get First Contentlet": {
"prefix": "dcfirst",
"body": [
"#if (\\$UtilMethods.isSet(\\$$1.results) && \\$${1:label}.results.size() == 1)",
"\t#set (\\$$2 = \\$${1:label}.results.get(0))",
"#end"
],
"description": "Get first contentlet from a list of Content Maps"
},
"dotcms: $dotcontent.pull() get All Contentlets": {
"prefix": "dcgetall",
"body": [
"#if (\\$UtilMethods.isSet(\\$${1:label}.results))",
"\t#set(\\$${1:label} = \\$${1:label}.results)",
"#end"
],
"description": "Put results list of dotcontent pull object into separate object"
},
"dotcms: $dotcontent.pullRelatedField()": {
"prefix": "dcrelated",
"body": [
"#set (\\$_relQuery = {",
"\t'id': \\$$identifier,",
"\t'field': \"ContentType.field\",",
"\t'cond': [",
"\t\t\"\"",
"\t],",
"\t'limit': 0,",
"\t'sort': \"modDate desc\"",
"})",
"#set (\\$$1 = \\$dotcontent.pullRelatedField(\\$_relQuery.id, \\$_relQuery.field, \\$UtilMethods.join(\\$_relQuery.cond, ' '), \\$_relQuery.limit, \\$_relQuery.sort))"
],
"description": "Pulls related contentlets with the same functionality as $dotcontent.pull()"
},
"dotcms: UtilMethods.isSet": {
"prefix": "isset",
"body": [
"\\$$UtilMethods.isSet($1)"
],
"description": "Check if variable is set"
},
"dotcms: UtilMethods.join": {
"prefix": "join",
"body": [
"\\$UtilMethods.join($1, $2)"
],
"description": "Join list with delimiter"
},
"dotcms: Velocity create variable": {
"prefix": "set",
"body": [
"#set (\\$$1 = $2)"
],
"description": "Create a Velocity Variable"
},
"dotcms VTLAPI: add JSON property": {
"prefix": "vtput",
"body": [
"$dotJSON.put(\"$1\", \"$2\")"
],
"description": "dotcms VTL API: Add JSON response property"
},
"dotcms VTLAPI: get body attribute": {
"prefix": "vtbodyget",
"body": [
"$bodyMap.get(\"$1\")"
],
"description": "dotcms VTL API: Get request body property"
},
"dotcms VTLAPI: Get Parameter": {
"prefix": "vtget",
"body": [
"$queryParams.get(\"$1\")"
],
"description": "dotcms VTL API: Get Query String Parameter"
},
"dotcms Request Wrapper: Get Parameter": {
"prefix": "rqgetrequestparam",
"body": "\\$request.getParameter(\"$1\")",
"description": "$request.getParameter()"
},
"dotcms Request Wrapper: Get Header": {
"prefix": "rqgetheader",
"body": "\\$request.getHeader(\"$1\")",
"description": "$request.getHeader()"
},
"dotcms Response Wrapper: Set Status": {
"prefix": "rssetstatus",
"body": "\\$response.setStatus(\"$1\")",
"description": "$response.setstatus()"
},
"dotcms Response Wrapper: Set Header": {
"prefix": "rssetheader",
"body": "\\$response.setHeader(\"$1\")",
"description": "$response.setHeader()"
}
}