-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompiledTemplateSales.js
335 lines (333 loc) · 12.8 KB
/
compiledTemplateSales.js
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
function pug_escape(e){var a=""+e,t=pug_match_html.exec(a);if(!t)return e;var r,c,n,s="";for(r=t.index,c=0;r<a.length;r++){switch(a.charCodeAt(r)){case 34:n=""";break;case 38:n="&";break;case 60:n="<";break;case 62:n=">";break;default:continue}c!==r&&(s+=a.substring(c,r)),c=r+1,s+=n}return c!==r?s+a.substring(c,r):s}
var pug_match_html=/["&<>]/;function template(locals) {const embeddedLinguisticResources = {"verbs":{},"words":{},"adjectives":{}};var pug_html = "", protect_stack = [], pug_mixins = {}, pug_interp;;
var locals_for_with = (locals || {});
(function (JSON, Object, console, data, embeddedLinguisticResources, params, synHelper1, util) {
/**
* @license
* Copyright 2021 Ludan Stoecklé
* SPDX-License-Identifier: Apache-2.0
*/
//-------- allows core to communicate with the inner of the template mechanic already used by Pug (i.e. pug_html)
util.setSpy({
getPugHtml: function () {
return pug_html;
},
setPugHtml: function (new_pug_html) {
pug_html = new_pug_html;
},
appendPugHtml: function (append) {
pug_html = pug_html + append;
},
});
util.setEmbeddedLinguisticResources(embeddedLinguisticResources);
/**
* @license
* Copyright 2021 Ludan Stoecklé
* SPDX-License-Identifier: Apache-2.0
*/
//-------- using GenderNumberManager
function setRefGender(obj, gender) {
util.genderNumberManager.setRefGender(obj, gender, null);
}
function getRefGender(obj) {
return util.genderNumberManager.getRefGender(obj);
}
function setRefNumber(obj, number) {
util.genderNumberManager.setRefNumber(obj, number);
}
function getRefNumber(obj) {
return util.genderNumberManager.getRefNumber(obj);
}
function setRefGenderNumber(obj, gender, number) {
util.genderNumberManager.setRefGenderNumber(obj, gender, number);
}
function getAnonymous(gender, number) {
return util.genderNumberManager.getAnonymous(gender, number);
}
function getAnonMS() {
return util.genderNumberManager.getAnonMS();
}
function getAnonMP() {
return util.genderNumberManager.getAnonMP();
}
function getAnonFS() {
return util.genderNumberManager.getAnonFS();
}
function getAnonFP() {
return util.genderNumberManager.getAnonFP();
}
//-------- using RefsManager
function resetRep(obj) {
util.refsManager.resetRep(obj);
}
function hasTriggeredRef(obj) {
return util.refsManager.hasTriggeredRef(obj);
}
function setTriggeredRef(obj) {
util.refsManager.setTriggeredRef(obj);
}
function dumpRefMap() {
util.refsManager.dumpRefMap();
}
function getNextRep(obj, params) {
return util.refsManager.getNextRep(obj, params);
}
//-------- using SaidManager
function dumpHasSaid() {
util.saidManager.dumpHasSaid();
}
function getDumpHasSaid() {
return util.saidManager.getDumpHasSaid();
}
function getHasSaidCopy() {
return util.saidManager.getHasSaidCopy();
}
function recordSaid(key) {
util.saidManager.recordSaid(key);
}
function deleteSaid(key) {
util.saidManager.deleteSaid(key);
}
function hasSaid(key) {
return util.saidManager.hasSaid(key);
}
function recordValue(key, value) {
util.getSaidManager().recordValue(key, value);
}
function deleteValue(key) {
util.getSaidManager().deleteValue(key);
}
function getValue(key) {
return util.getSaidManager().getValue(key);
}
//-------- using helper
function hasFlag(params, flag) {
return util.helper.hasFlag(params, flag);
}
function getFlagValue(params, flag) {
return util.helper.getFlagValue(params, flag);
}
function protectString(string) {
return util.helper.protectString(string);
}
function isSentenceStart() {
return util.helper.isSentenceStart();
}
function getMorF(table, obj) {
return util.helper.getMFN(table, obj);
}
function getMFN(table, obj) {
return util.helper.getMFN(table, obj);
}
function getSorP(table, obj) {
return util.helper.getSorP(table, obj);
}
//-------- using DictManager
function setWordData(word, wordData) {
util.languageImpl.getDictManager().setWordData(word, wordData);
}
function setAdjData(word, wordData) {
util.languageImpl.getDictManager().setAdjData(word, wordData);
}
/**
* @license
* Copyright 2021 Ludan Stoecklé
* SPDX-License-Identifier: Apache-2.0
*/
function syn_fct(items) {
return util.synManager.synFct(items);
}
function printObj(before, obj) {
console.log(before + ' ' + JSON.stringify(obj).substring(0, 20));
}
function logParams(params) {
console.log('params: ' + JSON.stringify(params));
}
function valueToSorP(val) {
return util.languageImpl.isPlural(val) ? 'P' : 'S';
}
function debug(filename, line) {
if (filename !== null) {
pug_debug_filename = filename;
}
pug_debug_line = line;
if (locals.renderDebug) {
// locals is available
let id = line;
if (filename !== null) {
id = filename.replace(/"/g, '') + ': ' + id;
}
pug_html = pug_html + `<span class="rosaenlg-debug" id="${id}"></span>`;
}
}
pug_mixins["foreach"] = pug_interp = function(elts, mixinFct, asm, params){ // NAME_foreach
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.asmManager.foreach(elts, mixinFct, asm, params);
};
var foreach=pug_mixins["foreach"];
pug_mixins["value"] = pug_interp = function(obj, params){ // NAME_value
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.valueManager.value(obj, params);
};
var value=pug_mixins["value"];
pug_mixins["syn"] = pug_interp = function(){ // NAME_syn
var block = (this && this.block), attributes = (this && this.attributes) || {};
var items = [];
for (pug_interp = 0; pug_interp < arguments.length; pug_interp++) {
items.push(arguments[pug_interp]);
}
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.synManager.simpleSyn(items);
};
var syn=pug_mixins["syn"];
pug_mixins["agreeAdj"] = pug_interp = function(adjective, subject, params){ // NAME_agreeAdj
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.adjectiveManager.agreeAdj(adjective, subject, params);
};
var agreeAdj=pug_mixins["agreeAdj"];
pug_mixins["recipientPossession"] = pug_interp = function(owned){ // NAME_recipientPossession
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.possessiveManager.recipientPossession(owned);
};
var recipientPossession=pug_mixins["recipientPossession"];
pug_mixins["thirdPossession"] = pug_interp = function(owner, owned, params){ // NAME_thirdPossession
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.possessiveManager.thirdPossession(owner, owned, params);
};
var thirdPossession=pug_mixins["thirdPossession"];
pug_mixins["dummy"] = pug_interp = function(){ // NAME_dummy
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
pug_mixins['dummy']();
};
var dummy=pug_mixins["dummy"];
pug_mixins["flushBuffer"] = pug_interp = function(){ // NAME_flushBuffer
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
pug_html = pug_html + "¤¤";
};
var flushBuffer=pug_mixins["flushBuffer"];
pug_mixins["eatSpace"] = pug_interp = function(){ // NAME_eatSpace
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
pug_html = pug_html + "¤EATSPACE¤";
};
var eatSpace=pug_mixins["eatSpace"];
pug_mixins["uppercaseWords"] = pug_interp = function(str){ // NAME_uppercaseWords
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
pug_html = pug_html + "¤" + (pug_escape(null == (pug_interp = util.helper.getUppercaseWords(str)) ? "" : pug_interp)) + "¤";
};
var uppercaseWords=pug_mixins["uppercaseWords"];
pug_mixins["toHtmlList"] = pug_interp = function(obj){ // NAME_toHtmlList
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
pug_html = pug_html + "\u003Cul\u003E";
// iterate obj
;(function(){
var $$obj = obj;
if ('number' == typeof $$obj.length) {
for (var index = 0, $$l = $$obj.length; index < $$l; index++) {
var val = $$obj[index];
if (val!=null && typeof(val) == "object") {
pug_html = pug_html + "\u003Cli\u003E" + "¤" + (pug_escape(null == (pug_interp = index) ? "" : pug_interp)) + "¤" + "¤: ¤";
pug_mixins["toHtmlList"](val);
pug_html = pug_html + "¤¤\u003C\u002Fli\u003E";
}
else {
pug_html = pug_html + "\u003Cli\u003E" + "¤" + (pug_escape(null == (pug_interp = index + ': ' + val) ? "" : pug_interp)) + "¤" + "\u003C\u002Fli\u003E";
}
}
} else {
var $$l = 0;
for (var index in $$obj) {
$$l++;
var val = $$obj[index];
if (val!=null && typeof(val) == "object") {
pug_html = pug_html + "\u003Cli\u003E" + "¤" + (pug_escape(null == (pug_interp = index) ? "" : pug_interp)) + "¤" + "¤: ¤";
pug_mixins["toHtmlList"](val);
pug_html = pug_html + "¤¤\u003C\u002Fli\u003E";
}
else {
pug_html = pug_html + "\u003Cli\u003E" + "¤" + (pug_escape(null == (pug_interp = index + ': ' + val) ? "" : pug_interp)) + "¤" + "\u003C\u002Fli\u003E";
}
}
}
}).call(this);
pug_html = pug_html + "\u003C\u002Ful\u003E";
};
var toHtmlList=pug_mixins["toHtmlList"];
pug_mixins["verb"] = pug_interp = function(subject, verbInfo, params){ // NAME_verb
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.sentenceManager.verb(subject, verbInfo, params);
};
var verb=pug_mixins["verb"];
pug_mixins["subjectVerb"] = pug_interp = function(subject, verbInfo, params){ // NAME_subjectVerb
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.sentenceManager.subjectVerb(subject, verbInfo, params);
};
var subjectVerb=pug_mixins["subjectVerb"];
pug_mixins["subjectVerbAdj"] = pug_interp = function(subject, verbInfo, adjective, params){ // NAME_subjectVerbAdj
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.sentenceManager.subjectVerbAdj(subject, verbInfo, adjective, params);
};
var subjectVerbAdj=pug_mixins["subjectVerbAdj"];
pug_mixins["verbPart"] = pug_interp = function(){ // NAME_verbPart
var block = (this && this.block), attributes = (this && this.attributes) || {};
function addToParams(_toAdd) { return Object.assign({}, params, _toAdd); }
util.verbsManager.popVerbPartInBuffer()
};
var verbPart=pug_mixins["verbPart"];
// default value if not provided in the parameters
data = data || {
salesQty: 1000,
salesAmount: 500000,
}
pug_mixins['synHelper1'] = pug_interp = function(pos){
switch(pos){
case 1:
pug_html = pug_html + "¤¤";
pug_mixins["value"](data.salesQty);
pug_html = pug_html + "¤ items were sold¤¤\n¤¤for a total amount of ¤";
pug_mixins["value"](data.salesAmount, {'FORMAT': '0a$'});
pug_html = pug_html + "¤¤";
break;
case 2:
pug_html = pug_html + "¤total sales were ¤";
pug_mixins["value"](data.salesAmount, {'FORMAT': '0a$'});
pug_html = pug_html + "¤ for ¤";
pug_mixins["value"](data.salesQty);
pug_html = pug_html + "¤ items¤";
break;
}
};
var synHelper1=pug_mixins["synHelper1"];
util.synManager.runSynz(synHelper1, 'synHelper1', 2, Object.assign({}, undefined, {}));
pug_html = pug_html + "¤.¤";
}.call(this, "JSON" in locals_for_with ?
locals_for_with.JSON :
typeof JSON !== 'undefined' ? JSON : undefined, "Object" in locals_for_with ?
locals_for_with.Object :
typeof Object !== 'undefined' ? Object : undefined, "console" in locals_for_with ?
locals_for_with.console :
typeof console !== 'undefined' ? console : undefined, "data" in locals_for_with ?
locals_for_with.data :
typeof data !== 'undefined' ? data : undefined, "embeddedLinguisticResources" in locals_for_with ?
locals_for_with.embeddedLinguisticResources :
typeof embeddedLinguisticResources !== 'undefined' ? embeddedLinguisticResources : undefined, "params" in locals_for_with ?
locals_for_with.params :
typeof params !== 'undefined' ? params : undefined, "synHelper1" in locals_for_with ?
locals_for_with.synHelper1 :
typeof synHelper1 !== 'undefined' ? synHelper1 : undefined, "util" in locals_for_with ?
locals_for_with.util :
typeof util !== 'undefined' ? util : undefined));
;;return locals.util.getFiltered();}
export default template;