MCPcopy Index your code
hub / github.com/totaljs/framework / view_find_command

Function view_find_command

internal.js:2443–2482  ·  view source on GitHub ↗
(content, index, entire)

Source from the content-addressed store, hash-verified

2441}
2442
2443function view_find_command(content, index, entire) {
2444
2445 index = content.indexOf('@{', index);
2446 if (index === -1)
2447 return null;
2448
2449 var length = content.length;
2450 var count = 0;
2451
2452 for (var i = index + 2; i < length; i++) {
2453 var c = content[i];
2454
2455 if (c === '{') {
2456 count++;
2457 continue;
2458 }
2459
2460 if (c !== '}')
2461 continue;
2462 else if (count > 0) {
2463 count--;
2464 continue;
2465 }
2466
2467 var command = content.substring(index + 2, i).trim();
2468
2469 // @{{ SKIP }}
2470 if (command[0] === '{')
2471 return view_find_command(content, index + 1);
2472
2473 var obj = { beg: index, end: i, line: view_line_counter(content.substr(0, index)), command: command };
2474
2475 if (entire)
2476 obj.phrase = content.substring(index, i + 1);
2477
2478 return obj;
2479 }
2480
2481 return null;
2482}
2483
2484function view_line_counter(value) {
2485 var count = value.match(/\n/g);

Callers 2

view_parseFunction · 0.85
markupFunction · 0.85

Calls 1

view_line_counterFunction · 0.85

Tested by

no test coverage detected