(content, index, entire)
| 2441 | } |
| 2442 | |
| 2443 | function 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 | |
| 2484 | function view_line_counter(value) { |
| 2485 | var count = value.match(/\n/g); |
no test coverage detected