Rev | Line | |
---|
[439] | 1 | var snippets = new Array();
|
---|
| 2 | var i = 0;
|
---|
| 3 | <?php
|
---|
| 4 |
|
---|
| 5 | function get_all_parts($string)
|
---|
| 6 | {
|
---|
| 7 | preg_match_all('#<!--(.*?)-->(.*?)<!--/.*?-->#s',$string,$matches);
|
---|
| 8 |
|
---|
| 9 | $array=array();
|
---|
| 10 | for ($i=0;$i<count($matches[1]);$i++)
|
---|
| 11 | {
|
---|
| 12 | $array[$matches[1][$i]] = $matches[2][$i];
|
---|
| 13 | }
|
---|
| 14 | return $array;
|
---|
| 15 | }
|
---|
| 16 | $snippets = file_get_contents('snippets.html');
|
---|
| 17 |
|
---|
| 18 | $matches = get_all_parts($snippets);
|
---|
| 19 | foreach ($matches as $name =>$html)
|
---|
| 20 | {
|
---|
| 21 | print "snippets[i] = new Object();\n";
|
---|
| 22 | print "snippets[i]['id'] = '$name';\n";
|
---|
| 23 | print "snippets[i]['HTML'] = '".str_replace("\n",'\n',addcslashes($html,"'"))."';\n";
|
---|
| 24 | print "i++;\n";
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | ?> |
---|
Note: See
TracBrowser
for help on using the repository browser.