UNPKG

22.5 kBHTMLView Raw
1<!DOCTYPE html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <title>JSDoc: Class: HTML_ADAPTER</title>
6
7 <script src="scripts/prettify/prettify.js"> </script>
8 <script src="scripts/prettify/lang-css.js"> </script>
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
13 <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14</head>
15
16<body>
17
18<div id="main">
19
20 <h1 class="page-title">Class: HTML_ADAPTER</h1>
21
22
23
24
25
26
27<section>
28
29<header>
30
31 <h2>HTML_ADAPTER</h2>
32
33 <div class="class-description"><p>HTML response adapter class which renders templates from provided data and template names</p></div>
34
35
36</header>
37
38<article>
39 <div class="container-overview">
40
41
42
43
44 <h2>Constructor</h2>
45
46
47 <h4 class="name" id="HTML_ADAPTER"><span class="type-signature"></span>new HTML_ADAPTER<span class="signature">(options)</span><span class="type-signature"></span></h4>
48
49
50
51
52
53
54
55
56
57
58
59
60
61 <h5>Parameters:</h5>
62
63
64<table class="params">
65 <thead>
66 <tr>
67
68 <th>Name</th>
69
70
71 <th>Type</th>
72
73
74
75
76
77 <th class="last">Description</th>
78 </tr>
79 </thead>
80
81 <tbody>
82
83
84 <tr>
85
86 <td class="name"><code>options</code></td>
87
88
89 <td class="type">
90
91
92<span class="param-type">Object</span>
93
94
95
96 </td>
97
98
99
100
101
102 <td class="description last"><p>Configurable options for HTML adapter</p>
103 <h6>Properties</h6>
104
105
106<table class="params">
107 <thead>
108 <tr>
109
110 <th>Name</th>
111
112
113 <th>Type</th>
114
115
116 <th>Attributes</th>
117
118
119
120 <th>Default</th>
121
122
123 <th class="last">Description</th>
124 </tr>
125 </thead>
126
127 <tbody>
128
129
130 <tr>
131
132 <td class="name"><code>engine</code></td>
133
134
135 <td class="type">
136
137
138<span class="param-type">Object</span>
139
140
141
142 </td>
143
144
145 <td class="attributes">
146
147 &lt;optional><br>
148
149
150
151
152
153 </td>
154
155
156
157 <td class="default">
158
159 ejs
160
161 </td>
162
163
164 <td class="description last"><p>Defines which templating engine to use when rendering template files</p>
165 <h6>Properties</h6>
166
167
168<table class="params">
169 <thead>
170 <tr>
171
172 <th>Name</th>
173
174
175 <th>Type</th>
176
177
178
179
180
181 <th class="last">Description</th>
182 </tr>
183 </thead>
184
185 <tbody>
186
187
188 <tr>
189
190 <td class="name"><code>render</code></td>
191
192
193 <td class="type">
194
195
196<span class="param-type">function</span>
197
198
199
200 </td>
201
202
203
204
205
206 <td class="description last"><p>If providing a custom rendering engine module must include a .render function which is synchronous or returns a Promise. Render function should also expect the following arguments in this order: (template_string, template_data, options)</p></td>
207 </tr>
208
209
210 </tbody>
211</table>
212
213 </td>
214 </tr>
215
216
217
218 <tr>
219
220 <td class="name"><code>engine_configuration</code></td>
221
222
223 <td class="type">
224
225
226<span class="param-type">Object</span>
227
228
229
230 </td>
231
232
233 <td class="attributes">
234
235 &lt;optional><br>
236
237
238
239
240
241 </td>
242
243
244
245 <td class="default">
246
247 </td>
248
249
250 <td class="description last"><p>Defines a default set of configuration options that are passed to the rendering function</p></td>
251 </tr>
252
253
254
255 <tr>
256
257 <td class="name"><code>extname</code></td>
258
259
260 <td class="type">
261
262
263<span class="param-type">string</span>
264
265
266
267 </td>
268
269
270 <td class="attributes">
271
272 &lt;optional><br>
273
274
275
276
277
278 </td>
279
280
281
282 <td class="default">
283
284 </td>
285
286
287 <td class="description last"><p>Name of a periodicjs extension. Used in finding valid template</p></td>
288 </tr>
289
290
291
292 <tr>
293
294 <td class="name"><code>themename</code></td>
295
296
297 <td class="type">
298
299
300<span class="param-type">string</span>
301
302
303
304 </td>
305
306
307 <td class="attributes">
308
309 &lt;optional><br>
310
311
312
313
314
315 </td>
316
317
318
319 <td class="default">
320
321 "periodicjs.theme.default"
322
323 </td>
324
325
326 <td class="description last"><p>Name of a periodicjs theme. Used in finding valid template</p></td>
327 </tr>
328
329
330
331 <tr>
332
333 <td class="name"><code>locals</code></td>
334
335
336 <td class="type">
337
338
339<span class="param-type">Object</span>
340
341
342
343 </td>
344
345
346 <td class="attributes">
347
348 &lt;optional><br>
349
350
351
352
353
354 </td>
355
356
357
358 <td class="default">
359
360 {}
361
362 </td>
363
364
365 <td class="description last"><p>Shared local values for rendering. Only used when express rendering is not available.</p></td>
366 </tr>
367
368
369
370 <tr>
371
372 <td class="name"><code>viewname</code></td>
373
374
375 <td class="type">
376
377
378<span class="param-type">string</span>
379
380
381
382 </td>
383
384
385 <td class="attributes">
386
387 &lt;optional><br>
388
389
390
391
392
393 </td>
394
395
396
397 <td class="default">
398
399 </td>
400
401
402 <td class="description last"><p>Defines a default view name that should be used in rendering</p></td>
403 </tr>
404
405
406
407 <tr>
408
409 <td class="name"><code>fileext</code></td>
410
411
412 <td class="type">
413
414
415<span class="param-type">string</span>
416
417
418
419 </td>
420
421
422 <td class="attributes">
423
424 &lt;optional><br>
425
426
427
428
429
430 </td>
431
432
433
434 <td class="default">
435
436 ".ejs"
437
438 </td>
439
440
441 <td class="description last"><p>Defines the default extension name of the template file</p></td>
442 </tr>
443
444
445 </tbody>
446</table>
447
448 </td>
449 </tr>
450
451
452 </tbody>
453</table>
454
455
456
457
458
459
460<dl class="details">
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487 <dt class="tag-source">Source:</dt>
488 <dd class="tag-source"><ul class="dummy"><li>
489 <a href="adapters_html_content.js.html">adapters/html_content.js</a>, <a href="adapters_html_content.js.html#line93">line 93</a>
490 </li></ul></dd>
491
492
493
494
495
496
497
498</dl>
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516 </div>
517
518
519 <h3 class="subsection-title">Extends</h3>
520
521
522
523
524 <ul>
525 <li>JSON_Adapter</li>
526 </ul>
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542 <h3 class="subsection-title">Methods</h3>
543
544
545
546
547
548
549 <h4 class="name" id="error"><span class="type-signature"></span>error<span class="signature">(err, options<span class="signature-attributes">opt</span>, cb)</span><span class="type-signature"> &rarr; {Object}</span></h4>
550
551
552
553
554
555<div class="description">
556 <p>Renders error view from template</p>
557</div>
558
559
560
561
562
563
564
565
566
567 <h5>Parameters:</h5>
568
569
570<table class="params">
571 <thead>
572 <tr>
573
574 <th>Name</th>
575
576
577 <th>Type</th>
578
579
580 <th>Attributes</th>
581
582
583
584 <th>Default</th>
585
586
587 <th class="last">Description</th>
588 </tr>
589 </thead>
590
591 <tbody>
592
593
594 <tr>
595
596 <td class="name"><code>err</code></td>
597
598
599 <td class="type">
600
601
602<span class="param-type">*</span>
603
604
605
606 </td>
607
608
609 <td class="attributes">
610
611
612
613
614
615 </td>
616
617
618
619 <td class="default">
620
621 </td>
622
623
624 <td class="description last"><p>Any error data that should be passed to template</p></td>
625 </tr>
626
627
628
629 <tr>
630
631 <td class="name"><code>options</code></td>
632
633
634 <td class="type">
635
636
637<span class="param-type">Object</span>
638
639
640
641 </td>
642
643
644 <td class="attributes">
645
646 &lt;optional><br>
647
648
649
650
651
652 </td>
653
654
655
656 <td class="default">
657
658 {}
659
660 </td>
661
662
663 <td class="description last"><p>Configurable options for rendering see _ERROR for full details</p>
664 <h6>Properties</h6>
665
666
667<table class="params">
668 <thead>
669 <tr>
670
671 <th>Name</th>
672
673
674 <th>Type</th>
675
676
677 <th>Attributes</th>
678
679
680
681 <th>Default</th>
682
683
684 <th class="last">Description</th>
685 </tr>
686 </thead>
687
688 <tbody>
689
690
691 <tr>
692
693 <td class="name"><code>formatError</code></td>
694
695
696 <td class="type">
697
698
699<span class="param-type">function</span>
700
701
702
703 </td>
704
705
706 <td class="attributes">
707
708 &lt;optional><br>
709
710
711
712
713
714 </td>
715
716
717
718 <td class="default">
719
720 _RENDER
721
722 </td>
723
724
725 <td class="description last"><p>Custom rendering function. It is not recommended to override the default value of this property and may no longer work properly</p></td>
726 </tr>
727
728
729
730 <tr>
731
732 <td class="name"><code>req</code></td>
733
734
735 <td class="type">
736
737
738<span class="param-type">Object</span>
739
740
741
742 </td>
743
744
745 <td class="attributes">
746
747 &lt;optional><br>
748
749
750
751
752
753 </td>
754
755
756
757 <td class="default">
758
759 </td>
760
761
762 <td class="description last"><p>Express request object. If options.req and options.res are defined the express .render method will be used to render template</p></td>
763 </tr>
764
765
766
767 <tr>
768
769 <td class="name"><code>res</code></td>
770
771
772 <td class="type">
773
774
775<span class="param-type">Object</span>
776
777
778
779 </td>
780
781
782 <td class="attributes">
783
784 &lt;optional><br>
785
786
787
788
789
790 </td>
791
792
793
794 <td class="default">
795
796 </td>
797
798
799 <td class="description last"><p>Express response object. If options.res and options.req are defined the express .render method will be used to render template</p></td>
800 </tr>
801
802
803
804 <tr>
805
806 <td class="name"><code>skip_response</code></td>
807
808
809 <td class="type">
810
811
812<span class="param-type">Boolean</span>
813
814
815
816 </td>
817
818
819 <td class="attributes">
820
821 &lt;optional><br>
822
823
824
825
826
827 </td>
828
829
830
831 <td class="default">
832
833 </td>
834
835
836 <td class="description last"><p>If true function will resolve with the rendered</p></td>
837 </tr>
838
839
840 </tbody>
841</table>
842
843 </td>
844 </tr>
845
846
847
848 <tr>
849
850 <td class="name"><code>cb</code></td>
851
852
853 <td class="type">
854
855
856<span class="param-type">function</span>
857
858
859
860 </td>
861
862
863 <td class="attributes">
864
865
866
867
868
869 </td>
870
871
872
873 <td class="default">
874
875 </td>
876
877
878 <td class="description last"><p>Optional callback function. If arugment is not passed function will</p></td>
879 </tr>
880
881
882 </tbody>
883</table>
884
885
886
887
888
889
890<dl class="details">
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917 <dt class="tag-source">Source:</dt>
918 <dd class="tag-source"><ul class="dummy"><li>
919 <a href="adapters_html_content.js.html">adapters/html_content.js</a>, <a href="adapters_html_content.js.html#line171">line 171</a>
920 </li></ul></dd>
921
922
923
924
925
926
927
928</dl>
929
930
931
932
933
934
935
936
937
938
939
940
941
942<h5>Returns:</h5>
943
944
945<div class="param-desc">
946 <p>Returns a Promise if cb arguement is not provided</p>
947</div>
948
949
950
951<dl>
952 <dt>
953 Type
954 </dt>
955 <dd>
956
957<span class="param-type">Object</span>
958
959
960 </dd>
961</dl>
962
963
964
965
966
967
968
969
970
971
972 <h4 class="name" id="render"><span class="type-signature"></span>render<span class="signature">(data, options<span class="signature-attributes">opt</span>, cb)</span><span class="type-signature"> &rarr; {Object}</span></h4>
973
974
975
976
977
978<div class="description">
979 <p>Renders HTML from provided data and template</p>
980</div>
981
982
983
984
985
986
987
988
989
990 <h5>Parameters:</h5>
991
992
993<table class="params">
994 <thead>
995 <tr>
996
997 <th>Name</th>
998
999
1000 <th>Type</th>
1001
1002
1003 <th>Attributes</th>
1004
1005
1006
1007 <th>Default</th>
1008
1009
1010 <th class="last">Description</th>
1011 </tr>
1012 </thead>
1013
1014 <tbody>
1015
1016
1017 <tr>
1018
1019 <td class="name"><code>data</code></td>
1020
1021
1022 <td class="type">
1023
1024
1025<span class="param-type">Object</span>
1026
1027
1028
1029 </td>
1030
1031
1032 <td class="attributes">
1033
1034
1035
1036
1037
1038 </td>
1039
1040
1041
1042 <td class="default">
1043
1044 </td>
1045
1046
1047 <td class="description last"><p>Data that is passed to render template</p></td>
1048 </tr>
1049
1050
1051
1052 <tr>
1053
1054 <td class="name"><code>options</code></td>
1055
1056
1057 <td class="type">
1058
1059
1060<span class="param-type">Object</span>
1061
1062
1063
1064 </td>
1065
1066
1067 <td class="attributes">
1068
1069 &lt;optional><br>
1070
1071
1072
1073
1074
1075 </td>
1076
1077
1078
1079 <td class="default">
1080
1081 {}
1082
1083 </td>
1084
1085
1086 <td class="description last"><p>Configurable options for rendering see _RENDER for full details</p>
1087 <h6>Properties</h6>
1088
1089
1090<table class="params">
1091 <thead>
1092 <tr>
1093
1094 <th>Name</th>
1095
1096
1097 <th>Type</th>
1098
1099
1100 <th>Attributes</th>
1101
1102
1103
1104 <th>Default</th>
1105
1106
1107 <th class="last">Description</th>
1108 </tr>
1109 </thead>
1110
1111 <tbody>
1112
1113
1114 <tr>
1115
1116 <td class="name"><code>formatRender</code></td>
1117
1118
1119 <td class="type">
1120
1121
1122<span class="param-type">function</span>
1123
1124
1125
1126 </td>
1127
1128
1129 <td class="attributes">
1130
1131 &lt;optional><br>
1132
1133
1134
1135
1136
1137 </td>
1138
1139
1140
1141 <td class="default">
1142
1143 _RENDER
1144
1145 </td>
1146
1147
1148 <td class="description last"><p>Custom rendering function. It is not recommended to override the default value of this property and may no longer work properly</p></td>
1149 </tr>
1150
1151
1152
1153 <tr>
1154
1155 <td class="name"><code>req</code></td>
1156
1157
1158 <td class="type">
1159
1160
1161<span class="param-type">Object</span>
1162
1163
1164
1165 </td>
1166
1167
1168 <td class="attributes">
1169
1170 &lt;optional><br>
1171
1172
1173
1174
1175
1176 </td>
1177
1178
1179
1180 <td class="default">
1181
1182 </td>
1183
1184
1185 <td class="description last"><p>Express request object. If options.req and options.res are defined the express .render method will be used to render template</p></td>
1186 </tr>
1187
1188
1189
1190 <tr>
1191
1192 <td class="name"><code>res</code></td>
1193
1194
1195 <td class="type">
1196
1197
1198<span class="param-type">Object</span>
1199
1200
1201
1202 </td>
1203
1204
1205 <td class="attributes">
1206
1207 &lt;optional><br>
1208
1209
1210
1211
1212
1213 </td>
1214
1215
1216
1217 <td class="default">
1218
1219 </td>
1220
1221
1222 <td class="description last"><p>Express response object. If options.res and options.req are defined the express .render method will be used to render template</p></td>
1223 </tr>
1224
1225
1226
1227 <tr>
1228
1229 <td class="name"><code>skip_response</code></td>
1230
1231
1232 <td class="type">
1233
1234
1235<span class="param-type">Boolean</span>
1236
1237
1238
1239 </td>
1240
1241
1242 <td class="attributes">
1243
1244 &lt;optional><br>
1245
1246
1247
1248
1249
1250 </td>
1251
1252
1253
1254 <td class="default">
1255
1256 </td>
1257
1258
1259 <td class="description last"><p>If true function will resolve with the rendered template instead of sending a response</p></td>
1260 </tr>
1261
1262
1263 </tbody>
1264</table>
1265
1266 </td>
1267 </tr>
1268
1269
1270
1271 <tr>
1272
1273 <td class="name"><code>cb</code></td>
1274
1275
1276 <td class="type">
1277
1278
1279<span class="param-type">function</span>
1280
1281
1282
1283 </td>
1284
1285
1286 <td class="attributes">
1287
1288
1289
1290
1291
1292 </td>
1293
1294
1295
1296 <td class="default">
1297
1298 </td>
1299
1300
1301 <td class="description last"><p>Optional callback function. If arugment is not passed function will</p></td>
1302 </tr>
1303
1304
1305 </tbody>
1306</table>
1307
1308
1309
1310
1311
1312
1313<dl class="details">
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340 <dt class="tag-source">Source:</dt>
1341 <dd class="tag-source"><ul class="dummy"><li>
1342 <a href="adapters_html_content.js.html">adapters/html_content.js</a>, <a href="adapters_html_content.js.html#line128">line 128</a>
1343 </li></ul></dd>
1344
1345
1346
1347
1348
1349
1350
1351</dl>
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365<h5>Returns:</h5>
1366
1367
1368<div class="param-desc">
1369 <p>Returns a Promise if cb arguement is not provided</p>
1370</div>
1371
1372
1373
1374<dl>
1375 <dt>
1376 Type
1377 </dt>
1378 <dd>
1379
1380<span class="param-type">Object</span>
1381
1382
1383 </dd>
1384</dl>
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396</article>
1397
1398</section>
1399
1400
1401
1402
1403</div>
1404
1405<nav>
1406 <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="CONTENT_ADAPTER_INTERFACE.html">CONTENT_ADAPTER_INTERFACE</a></li><li><a href="HTML_ADAPTER.html">HTML_ADAPTER</a></li><li><a href="JSON_ADAPTER.html">JSON_ADAPTER</a></li><li><a href="XML_ADAPTER.html">XML_ADAPTER</a></li></ul><h3>Global</h3><ul><li><a href="global.html#_ERROR">_ERROR</a></li><li><a href="global.html#_RENDER">_RENDER</a></li><li><a href="global.html#findValidViewFromPaths">findValidViewFromPaths</a></li></ul>
1407</nav>
1408
1409<br class="clear">
1410
1411<footer>
1412 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Thu Dec 22 2016 14:40:44 GMT-0500 (EST)
1413</footer>
1414
1415<script> prettyPrint(); </script>
1416<script src="scripts/linenumber.js"> </script>
1417</body>
1418</html>
\No newline at end of file