mahabhuta 0.7.7 → 0.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/TODO.md ADDED
@@ -0,0 +1,7 @@
1
+ # Ideas for things to do
2
+
3
+ **Implement a test suite**: This is a must, really.
4
+
5
+ **Implement a command-line tool**: It would take a module name to load that will contain Mahafuncs, then take input file and output file names.
6
+
7
+ **Do something more significant with Mahafunc bundles**:
package/index.js CHANGED
@@ -151,11 +151,13 @@ exports.PageProcessor = class PageProcessor extends exports.Mahafunc {
151
151
  const _mahaarray_name = Symbol('name');
152
152
  const _mahaarray_options = Symbol('options');
153
153
  const _mahaarray_functions = Symbol('functions');
154
+ const _mahaarray_final_functions = Symbol('final_functions');
154
155
 
155
156
  exports.MahafuncArray = class MahafuncArray {
156
157
 
157
158
  constructor(name, config) {
158
159
  this[_mahaarray_functions] = [];
160
+ this[_mahaarray_final_functions] = [];
159
161
  this[_mahaarray_name] = name;
160
162
  this[_mahaarray_options] = config;
161
163
  // console.log(`new MahafuncArray ${this[_mahaarray_name]} ${util.inspect(this[_mahaarray_options])}`);
@@ -167,6 +169,8 @@ exports.MahafuncArray = class MahafuncArray {
167
169
 
168
170
  get functions() { return this[_mahaarray_functions]; }
169
171
 
172
+ get final_functions() { return this[_mahaarray_final_functions]; }
173
+
170
174
  addMahafunc(func) {
171
175
  if (!(func instanceof exports.Mahafunc
172
176
  || func instanceof exports.MahafuncArray
@@ -195,87 +199,119 @@ exports.MahafuncArray = class MahafuncArray {
195
199
  }
196
200
  }
197
201
 
202
+ setFinalMahafuncArray(final_functions) {
203
+ if (!(Array.isArray(final_functions))) {
204
+ throw new Error("Improper mahafunction array "+ util.inspect(final_functions));
205
+ } else {
206
+ this[_mahaarray_final_functions] = final_functions;
207
+ for (let func of this[_mahaarray_final_functions]) {
208
+ if (func instanceof exports.Mahafunc) {
209
+ func.array = this;
210
+ }
211
+ }
212
+ }
213
+ }
214
+
215
+ addFinalMahafunc(func) {
216
+ if (!(func instanceof exports.Mahafunc
217
+ || func instanceof exports.MahafuncArray
218
+ || typeof func === 'function'
219
+ || Array.isArray(func))) {
220
+ throw new Error("Improper addition "+ util.inspect(func));
221
+ } else {
222
+ this.final_functions.push(func);
223
+ if (func instanceof exports.Mahafunc) {
224
+ func.array = this;
225
+ }
226
+ }
227
+ return this; // support chaining
228
+ }
229
+
198
230
  async process($, metadata, dirty) {
199
231
  if (traceFlag) console.log(`Mahabhuta starting array ${this.name}`);
200
232
  const loops = [];
201
233
  // const startProcessing = new Date();
202
- for (var mahafunc of this.functions) {
203
- if (mahafunc instanceof exports.CustomElement) {
204
- if (traceFlag) console.log(`Mahabhuta calling CustomElement ${this.name} ${mahafunc.elementName}`);
205
- try {
206
- await mahafunc.processAll($, metadata, dirty);
207
- } catch (errCustom) {
208
- throw new Error(`Mahabhuta ${this.name} caught error in CustomElement(${mahafunc.elementName}): ${errCustom.message}`);
209
- }
210
- // loops.push(`... CustomElement ${mahafunc.elementName} ${(new Date() - startProcessing) / 1000} seconds`);
211
- } else if (mahafunc instanceof exports.Munger) {
212
- if (traceFlag) console.log(`Mahabhuta calling Munger ${this.name} ${mahafunc.selector}`);
213
- try {
214
- await mahafunc.processAll($, metadata, dirty);
215
- } catch (errMunger) {
216
- throw new Error(`Mahabhuta ${this.name} caught error in Munger(${mahafunc.selector}): ${errMunger.message}`);
217
- }
218
- if (traceFlag) console.log(`Mahabhuta FINISHED Munger ${this.name} ${mahafunc.selector}`);
219
- // loops.push(`... Munger ${mahafunc.selector} ${(new Date() - startProcessing) / 1000} seconds`);
220
- } else if (mahafunc instanceof exports.PageProcessor) {
221
- // Performance testing
222
- let _start;
223
- if (tracePerf) _start = new Date();
224
- if (traceFlag) console.log(`Mahabhuta calling ${this.name} PageProcessor `);
225
- try {
226
- await mahafunc.process($, metadata, dirty);
227
- } catch (errPageProcessor) {
228
- throw new Error(`Mahabhuta ${this.name} caught error in PageProcessor: ${errPageProcessor.message}`);
229
- }
230
- // Performance testing
231
- if (tracePerf) console.log(`PageProcessor ${this.name} ${(new Date() - _start) / 1000} seconds`)
232
- // loops.push(`... PageProcessor ${(new Date() - startProcessing) / 1000} seconds`);
233
- } else if (mahafunc instanceof exports.MahafuncArray) {
234
- // Performance testing
235
- let _start;
236
- if (tracePerf) _start = new Date();
237
- let results = [];
238
- try {
239
- results = await mahafunc.process($, metadata, dirty);
240
- } catch (errMahafuncArray) {
241
- throw new Error(`Mahabhuta ${this.name} caught error in MahafuncArray: ${errMahafuncArray.message}`);
242
- }
243
- // Performance testing
244
- if (tracePerf) console.log(`MahafuncArray ${this.name} ${mahafunc.name} ${(new Date() - _start) / 1000} seconds`)
245
-
246
- // results.forEach(result => { loops.push(` ... "${mahafunc.name} result" ${result} ${(new Date() - startProcessing) / 1000} seconds`); });
247
- // loops.push(`... MahafuncArray ${mahafunc.name} ${(new Date() - startProcessing) / 1000} seconds`);
248
- } else if (typeof mahafunc === 'function') {
249
- // Performance testing
250
- let _start;
251
- if (tracePerf) _start = new Date();
252
- if (traceFlag) console.log(`Mahabhuta calling an ${this.name} "function" `);
253
- try {
254
- await new Promise((resolve, reject) => {
255
- mahafunc($, metadata, dirty, err => {
256
- if (err) reject(err);
257
- else resolve();
234
+
235
+ // Run the functions, then run the final_functions
236
+ for (let funclist of [ this.functions, this.final_functions]) {
237
+ for (let mahafunc of funclist) {
238
+ if (mahafunc instanceof exports.CustomElement) {
239
+ if (traceFlag) console.log(`Mahabhuta calling CustomElement ${this.name} ${mahafunc.elementName}`);
240
+ try {
241
+ await mahafunc.processAll($, metadata, dirty);
242
+ } catch (errCustom) {
243
+ throw new Error(`Mahabhuta ${this.name} caught error in CustomElement(${mahafunc.elementName}): ${errCustom.message}`);
244
+ }
245
+ // loops.push(`... CustomElement ${mahafunc.elementName} ${(new Date() - startProcessing) / 1000} seconds`);
246
+ } else if (mahafunc instanceof exports.Munger) {
247
+ if (traceFlag) console.log(`Mahabhuta calling Munger ${this.name} ${mahafunc.selector}`);
248
+ try {
249
+ await mahafunc.processAll($, metadata, dirty);
250
+ } catch (errMunger) {
251
+ throw new Error(`Mahabhuta ${this.name} caught error in Munger(${mahafunc.selector}): ${errMunger.message}`);
252
+ }
253
+ if (traceFlag) console.log(`Mahabhuta FINISHED Munger ${this.name} ${mahafunc.selector}`);
254
+ // loops.push(`... Munger ${mahafunc.selector} ${(new Date() - startProcessing) / 1000} seconds`);
255
+ } else if (mahafunc instanceof exports.PageProcessor) {
256
+ // Performance testing
257
+ let _start;
258
+ if (tracePerf) _start = new Date();
259
+ if (traceFlag) console.log(`Mahabhuta calling ${this.name} PageProcessor `);
260
+ try {
261
+ await mahafunc.process($, metadata, dirty);
262
+ } catch (errPageProcessor) {
263
+ throw new Error(`Mahabhuta ${this.name} caught error in PageProcessor: ${errPageProcessor.message}`);
264
+ }
265
+ // Performance testing
266
+ if (tracePerf) console.log(`PageProcessor ${this.name} ${(new Date() - _start) / 1000} seconds`)
267
+ // loops.push(`... PageProcessor ${(new Date() - startProcessing) / 1000} seconds`);
268
+ } else if (mahafunc instanceof exports.MahafuncArray) {
269
+ // Performance testing
270
+ let _start;
271
+ if (tracePerf) _start = new Date();
272
+ let results = [];
273
+ try {
274
+ results = await mahafunc.process($, metadata, dirty);
275
+ } catch (errMahafuncArray) {
276
+ throw new Error(`Mahabhuta ${this.name} caught error in MahafuncArray: ${errMahafuncArray.message}`);
277
+ }
278
+ // Performance testing
279
+ if (tracePerf) console.log(`MahafuncArray ${this.name} ${mahafunc.name} ${(new Date() - _start) / 1000} seconds`)
280
+
281
+ // results.forEach(result => { loops.push(` ... "${mahafunc.name} result" ${result} ${(new Date() - startProcessing) / 1000} seconds`); });
282
+ // loops.push(`... MahafuncArray ${mahafunc.name} ${(new Date() - startProcessing) / 1000} seconds`);
283
+ } else if (typeof mahafunc === 'function') {
284
+ // Performance testing
285
+ let _start;
286
+ if (tracePerf) _start = new Date();
287
+ if (traceFlag) console.log(`Mahabhuta calling an ${this.name} "function" `);
288
+ try {
289
+ await new Promise((resolve, reject) => {
290
+ mahafunc($, metadata, dirty, err => {
291
+ if (err) reject(err);
292
+ else resolve();
293
+ });
258
294
  });
259
- });
260
- } catch (errFunction) {
261
- throw new Error(`Mahabhuta ${this.name} caught error in function: ${errFunction.message}`);
295
+ } catch (errFunction) {
296
+ throw new Error(`Mahabhuta ${this.name} caught error in function: ${errFunction.message}`);
297
+ }
298
+ // Performance testing
299
+ if (tracePerf) console.log(`function ${this.name} ${(new Date() - _start) / 1000} seconds`)
300
+ // loops.push(`... MahafuncArray "function" ${(new Date() - startProcessing) / 1000} seconds`);
301
+ } else if (Array.isArray(mahafunc)) {
302
+ // Performance testing
303
+ let _start;
304
+ if (tracePerf) _start = new Date();
305
+ let mhObj = new exports.MahafuncArray("inline", this._config);
306
+ mhObj.setMahafuncArray(mahafunc);
307
+ let results = await mhObj.process($, metadata, dirty);
308
+ // Performance testing
309
+ if (tracePerf) console.log(`Array ${this.name} inline ${(new Date() - _start) / 1000} seconds`)
310
+ // results.forEach(result => { loops.push(` ... "inline result" ${result} ${(new Date() - startProcessing) / 1000} seconds`); });
311
+ // loops.push(`... MahafuncArray "inline array" ${(new Date() - startProcessing) / 1000} seconds`);
312
+ } else {
313
+ console.error(`BAD MAHAFUNC in array ${this.name} - ${util.inspect(mahafunc)}`);
262
314
  }
263
- // Performance testing
264
- if (tracePerf) console.log(`function ${this.name} ${(new Date() - _start) / 1000} seconds`)
265
- // loops.push(`... MahafuncArray "function" ${(new Date() - startProcessing) / 1000} seconds`);
266
- } else if (Array.isArray(mahafunc)) {
267
- // Performance testing
268
- let _start;
269
- if (tracePerf) _start = new Date();
270
- let mhObj = new exports.MahafuncArray("inline", this._config);
271
- mhObj.setMahafuncArray(mahafunc);
272
- let results = await mhObj.process($, metadata, dirty);
273
- // Performance testing
274
- if (tracePerf) console.log(`Array ${this.name} inline ${(new Date() - _start) / 1000} seconds`)
275
- // results.forEach(result => { loops.push(` ... "inline result" ${result} ${(new Date() - startProcessing) / 1000} seconds`); });
276
- // loops.push(`... MahafuncArray "inline array" ${(new Date() - startProcessing) / 1000} seconds`);
277
- } else {
278
- console.error(`BAD MAHAFUNC in array ${this.name} - ${util.inspect(mahafunc)}`);
279
315
  }
280
316
  }
281
317
  // return $.html();
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "type": "git",
22
22
  "url": "https://github.com/akashacms/mahabhuta.git"
23
23
  },
24
- "version": "0.7.7",
24
+ "version": "0.7.8",
25
25
  "engines": {
26
26
  "node": ">=12.4"
27
27
  },
@@ -1,72 +0,0 @@
1
- 'use strict';
2
-
3
- const mahabhuta = require('mahabhuta');
4
- const maha = require('./maha');
5
-
6
- const express = require('express');
7
- const util = require('util');
8
- const path = require('path');
9
- const favicon = require('serve-favicon');
10
- const logger = require('morgan');
11
- const cookieParser = require('cookie-parser');
12
- const bodyParser = require('body-parser');
13
-
14
- const routes = require('./routes/index');
15
- const users = require('./routes/users');
16
-
17
- var app = express();
18
-
19
- // view engine setup
20
-
21
- // TODO add more mahafuncs here
22
- maha.addMahafunc(mahabhuta.builtin.mahabhuta);
23
- maha.partialDir(path.join(__dirname, "partials"));
24
- maha.registerExpress(app, "maha");
25
-
26
- app.set('views', path.join(__dirname, 'views'));
27
- app.set('view engine', 'maha');
28
-
29
- // uncomment after placing your favicon in /public
30
- //app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
31
- app.use(logger('dev'));
32
- app.use(bodyParser.json());
33
- app.use(bodyParser.urlencoded({ extended: false }));
34
- app.use(cookieParser());
35
- app.use(express.static(path.join(__dirname, 'public')));
36
-
37
- app.use('/', routes);
38
- app.use('/users', users);
39
-
40
- // catch 404 and forward to error handler
41
- app.use(function(req, res, next) {
42
- var err = new Error('Not Found');
43
- err.status = 404;
44
- next(err);
45
- });
46
-
47
- // error handlers
48
-
49
- // development error handler
50
- // will print stacktrace
51
- if (app.get('env') === 'development') {
52
- app.use(function(err, req, res, next) {
53
- res.status(err.status || 500);
54
- res.render('error', {
55
- message: err.message,
56
- error: err
57
- });
58
- });
59
- }
60
-
61
- // production error handler
62
- // no stacktraces leaked to user
63
- app.use(function(err, req, res, next) {
64
- res.status(err.status || 500);
65
- res.render('error', {
66
- message: err.message,
67
- error: {}
68
- });
69
- });
70
-
71
-
72
- module.exports = app;
@@ -1,90 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Module dependencies.
5
- */
6
-
7
- var app = require('../app');
8
- var debug = require('debug')('express:server');
9
- var http = require('http');
10
-
11
- /**
12
- * Get port from environment and store in Express.
13
- */
14
-
15
- var port = normalizePort(process.env.PORT || '3000');
16
- app.set('port', port);
17
-
18
- /**
19
- * Create HTTP server.
20
- */
21
-
22
- var server = http.createServer(app);
23
-
24
- /**
25
- * Listen on provided port, on all network interfaces.
26
- */
27
-
28
- server.listen(port);
29
- server.on('error', onError);
30
- server.on('listening', onListening);
31
-
32
- /**
33
- * Normalize a port into a number, string, or false.
34
- */
35
-
36
- function normalizePort(val) {
37
- var port = parseInt(val, 10);
38
-
39
- if (isNaN(port)) {
40
- // named pipe
41
- return val;
42
- }
43
-
44
- if (port >= 0) {
45
- // port number
46
- return port;
47
- }
48
-
49
- return false;
50
- }
51
-
52
- /**
53
- * Event listener for HTTP server "error" event.
54
- */
55
-
56
- function onError(error) {
57
- if (error.syscall !== 'listen') {
58
- throw error;
59
- }
60
-
61
- var bind = typeof port === 'string'
62
- ? 'Pipe ' + port
63
- : 'Port ' + port;
64
-
65
- // handle specific listen errors with friendly messages
66
- switch (error.code) {
67
- case 'EACCES':
68
- console.error(bind + ' requires elevated privileges');
69
- process.exit(1);
70
- break;
71
- case 'EADDRINUSE':
72
- console.error(bind + ' is already in use');
73
- process.exit(1);
74
- break;
75
- default:
76
- throw error;
77
- }
78
- }
79
-
80
- /**
81
- * Event listener for HTTP server "listening" event.
82
- */
83
-
84
- function onListening() {
85
- var addr = server.address();
86
- var bind = typeof addr === 'string'
87
- ? 'pipe ' + addr
88
- : 'port ' + addr.port;
89
- debug('Listening on ' + bind);
90
- }
@@ -1,92 +0,0 @@
1
- 'use strict';
2
-
3
- const mahabhuta = require('mahabhuta');
4
- const ejs = require('ejs');
5
- const fs = require('fs-extra-promise');
6
- const path = require('path');
7
- const util = require('util');
8
-
9
- var mahafuncs = new mahabhuta.MahafuncArray("mahabhuta-express-example", {});
10
-
11
- var partialDirName;
12
-
13
- exports.partialDir = function(_partialDir) {
14
- partialDirName = _partialDir;
15
- };
16
-
17
- exports.addMahafunc = function(newMahafuncs) {
18
- mahafuncs.addMahafunc(newMahafuncs);
19
- };
20
-
21
- exports.registerExpress = function(app, ext) {
22
- app.engine(ext, (filePath, options, callback) => {
23
- // console.log(`Mahabhuta Express Engine ${util.inspect(mahafuncs)}`);
24
- fs.readFile(filePath, 'utf8', (err, content) => {
25
- if (err) return callback(err);
26
- // console.log(`Mahabhuta Express Engine ${util.inspect(mahafuncs)}`);
27
- // console.log(`Mahabhuta Express Engine ${util.inspect(content)} ${util.inspect(options)}`)
28
- content = ejs.render(content.toString(), options);
29
- mahabhuta.process(content, options, mahafuncs, (err, html) => {
30
- if (err) { /* console.error(`Mahabhuta Express Engine ERROR ${err}`); */ callback(err); }
31
- else { /* console.log(`Mahabhuta OKAY: ${html}`); */ callback(undefined, html); }
32
- });
33
- });
34
- });
35
- // console.log(`Mahabhuta Express Engine constructor ${util.inspect(this)} ------ ${util.inspect(this.mahafuncs)}`);
36
- };
37
-
38
- mahabhuta.builtin.configuration.renderPartial = function(fileName, contentBody, metadata) {
39
- var partialPath = path.join(partialDirName, fileName);
40
- // console.log(`renderPartial ${fileName} ${partialPath} ${contentBody}`);
41
- return fs.statAsync(partialPath)
42
- .then(stats => {
43
- if (stats && stats.isFile()) {
44
- return fs.readFileAsync(partialPath, 'utf8');
45
- } else throw new Error(`Path ${partialPath} not a file`);
46
- })
47
- .then(fileData => {
48
- return new Promise((resolve, reject) => {
49
- // console.log(`renderPartial fileData ${fileData}`);
50
- var rendered = ejs.render(fileData, metadata, {});
51
- // console.log(`renderPartial rendered ${rendered}`);
52
- mahabhuta.process(rendered, metadata, mahafuncs, (err, html) => {
53
- if (err) { reject(err); }
54
- else {
55
- // console.log(`renderPartial html ${html}`);
56
- resolve(html);
57
- }
58
- });
59
- });
60
- });
61
- };
62
-
63
-
64
- /*
65
- TODO make the resulting application somewhat useful.
66
- * https://www.npmjs.com/package/lorem-hipsum
67
- * https://www.npmjs.com/package/lorem-ipsum
68
- * https://www.npmjs.com/package/lorem-pedia
69
- * https://www.npmjs.com/package/lipsumator
70
- * https://www.npmjs.com/package/placeholder-generator
71
- * https://www.npmjs.com/package/blindipsum
72
- * https://www.npmjs.com/package/chinesegen
73
- * https://www.npmjs.com/package/boganipsum
74
- * https://www.npmjs.com/package/vinoipsum
75
- * https://www.npmjs.com/package/hall-and-oates-ipsum
76
- * https://www.npmjs.com/package/schuler-ipsum
77
- * https://www.npmjs.com/package/anything-ipsum
78
- * https://www.npmjs.com/package/synergipsum
79
- * https://www.npmjs.com/package/smithers-loremipsum
80
- * https://www.npmjs.com/package/jack-ipsum
81
- * https://www.npmjs.com/package/englipsum
82
- * https://www.npmjs.com/package/kanyeloremipsum
83
- * https://www.npmjs.com/package/kanye-ipsum
84
- * https://www.npmjs.com/package/body-builder-ipsum
85
- * https://www.npmjs.com/package/hipsum
86
- * https://www.npmjs.com/package/ipsum
87
- * https://www.npmjs.com/package/schiffer-ipsum
88
- * https://www.npmjs.com/package/bavaria-ipsum
89
- * https://www.npmjs.com/package/lobsteripsum
90
- * https://www.npmjs.com/package/bacon-stream
91
- * https://www.npmjs.com/package/neah
92
- * https://www.npmjs.com/package/mayonnaise.js */
@@ -1,20 +0,0 @@
1
- {
2
- "name": "express",
3
- "version": "0.0.0",
4
- "private": true,
5
- "scripts": {
6
- "start": "node ./bin/www"
7
- },
8
- "dependencies": {
9
- "body-parser": "~1.15.1",
10
- "cheerio": "^0.22.0",
11
- "cookie-parser": "~1.4.3",
12
- "debug": "~3.1.0",
13
- "ejs": "^2.4.2",
14
- "express": "~4.13.4",
15
- "fs-extra-promise": "^0.4.1",
16
- "morgan": "~1.9.1",
17
- "serve-favicon": "~2.3.0",
18
- "mahabhuta": ">=0.5"
19
- }
20
- }
@@ -1,5 +0,0 @@
1
- <% if (sweets) { %>
2
- <ul>
3
- <% for (sweet in sweets) { %><li><%= sweets[sweet] %></li><% } %>
4
- </ul>
5
- <% } %>
@@ -1,7 +0,0 @@
1
- <div>
2
- <ul>
3
- <li>Item 1</li>
4
- <li>Item 2</li>
5
- <li>Item 3</li>
6
- </ul>
7
- </div>
@@ -1,8 +0,0 @@
1
- body {
2
- padding: 50px;
3
- font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
4
- }
5
-
6
- a {
7
- color: #00B7FF;
8
- }
@@ -1,18 +0,0 @@
1
- var express = require('express');
2
- var router = express.Router();
3
-
4
- /* GET home page. */
5
- router.get('/', function(req, res, next) {
6
- res.render('hello-world', {
7
- title: 'Express',
8
- sweets: [
9
- "Chocolate", "Strawberry", "Honey", "Kumquat"
10
- ]
11
- });
12
- });
13
-
14
- router.get('/foo', function(req, res, next) {
15
- res.render('index.ejs', { title: 'Express' });
16
- });
17
-
18
- module.exports = router;
@@ -1,9 +0,0 @@
1
- var express = require('express');
2
- var router = express.Router();
3
-
4
- /* GET users listing. */
5
- router.get('/', function(req, res, next) {
6
- res.send('respond with a resource');
7
- });
8
-
9
- module.exports = router;
@@ -1,3 +0,0 @@
1
- <h1><%= message %></h1>
2
- <h2><%= error.status %></h2>
3
- <pre><%= error.stack %></pre>
@@ -1,3 +0,0 @@
1
- <h1><%= message %></h1>
2
- <h2><%= error.status %></h2>
3
- <pre><%= error.stack %></pre>
@@ -1,15 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title><%= title %></title>
5
- <external-stylesheet href='/stylesheets/style.css' ></external-stylesheet>
6
- </head>
7
- <body>
8
- <h1><%= title %></h1>
9
- <p>Hello, World! Welcome to <%= title %></p>
10
- <table><tr>
11
- <td><partial file-name="test.html"></partial></td>
12
- <td><partial file-name="sweets.ejs"></partial></td>
13
- </tr></table>
14
- </body>
15
- </html>
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title><%= title %></title>
5
- <link rel='stylesheet' href='/stylesheets/style.css' />
6
- <external-stylesheet href='/stylesheets/style.css' ></external-stylesheet>
7
- </head>
8
- <body>
9
- <h1><%= title %></h1>
10
- <p>index.ejs Welcome to <%= title %></p>
11
- </body>
12
- </html>
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- const mahabhuta = require('../../index');
4
-
5
- var mahafuncs = new mahabhuta.MahafuncArray("example", {});
6
-
7
- class HelloWorld extends mahabhuta.CustomElement {
8
- get elementName() { return "hello-world"; }
9
- process($element, metadata, dirty) {
10
- return Promise.resolve("Hello, world!");
11
- }
12
- }
13
- mahafuncs.addMahafunc(new HelloWorld());
14
-
15
- mahabhuta.config({
16
- recognizeSelfClosing: true,
17
- recognizeCDATA: true
18
- });
19
-
20
- mahabhuta.process(`
21
- <html>
22
- <head>
23
- <title>Hi</title>
24
- </head>
25
- <body>
26
- <hello-world></hello-world>
27
- </body>
28
- </html>
29
- `, {}, mahafuncs, (err, html) => {
30
- if (err) console.error(err);
31
- else console.log(html);
32
- });