-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.tpl
More file actions
131 lines (113 loc) · 2.96 KB
/
Copy pathtemplate.tpl
File metadata and controls
131 lines (113 loc) · 2.96 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
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
___TERMS_OF_SERVICE___
By creating or modifying this file you agree to Google Tag Manager's Community
Template Gallery Developer Terms of Service available at
https://developers.google.com/tag-manager/gallery-tos (or such other URL as
Google may provide), as modified from time to time.
___INFO___
{
"type": "MACRO",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "Join Strings",
"description": "The join Strings returns the values as a string.\n\nThe elements will be separated by a specified separator. The default separator is comma (,).",
"categories": [
"UTILITY"
],
"containerContexts": [
"WEB"
]
}
___TEMPLATE_PARAMETERS___
[
{
"type": "SIMPLE_TABLE",
"name": "inputData",
"simpleTableColumns": [
{
"defaultValue": "",
"displayName": "Add values to concatenate:",
"name": "value",
"type": "TEXT",
"valueValidators": [
{
"type": "NON_EMPTY"
}
]
},
{
"defaultValue": true,
"displayName": "Mandatory value",
"name": "mandatory",
"type": "SELECT",
"selectItems": [
{
"value": true,
"displayValue": "true"
},
{
"value": false,
"displayValue": "false"
}
],
"valueValidators": [
{
"type": "NON_EMPTY"
}
]
}
]
},
{
"type": "GROUP",
"name": "group1",
"displayName": "Join options:",
"groupStyle": "ZIPPY_OPEN_ON_PARAM",
"subParams": [
{
"type": "TEXT",
"name": "separator",
"displayName": "Separator",
"simpleValueType": true,
"defaultValue": ",",
"valueHint": ","
}
]
},
{
"type": "LABEL",
"name": "info",
"displayName": "\u003cstrong\u003e\u003ca href\u003d\"https://www.luratic.com/posts/templates/variables/join-strings/\"\u003eDocumentation\u003c/a\u003e\u003c/strong\u003e"
},
{
"type": "LABEL",
"name": "info2",
"displayName": "\u003cstrong\u003e\u003ca href\u003d\"https://datola.es\"\u003eCommunity 📊\u003c/a\u003e\u003c/strong\u003e"
}
]
___SANDBOXED_JS_FOR_WEB_TEMPLATE___
const getType = require('getType');
const makeString = require('makeString');
const values = data.inputData;
const separator = data.separator;
let strings = [];
values.forEach(parameter => {
var type = getType(parameter.value);
let value = makeString(parameter.value);
let mandatory = parameter.mandatory;
let isRequired = type === 'undefined' && mandatory;
if(value !=='undefined' || isRequired) {
strings.push(value);
}
});
const join = strings.join(separator);
return join;
___TESTS___
scenarios: []
___NOTES___
Developed with ❤ by: Alfonso, Txema and Brais.
Web: www.luratic.com
Linkedin:
https://www.linkedin.com/in/braiscalvo/
https://www.linkedin.com/in/alfonsorc/
https://www.linkedin.com/in/txemasm/