| @@ 25-38 (lines=14) @@ | ||
| 22 | return Yii::$app->getView()->renderFile($path, $params); |
|
| 23 | } |
|
| 24 | ||
| 25 | public function extractData($path) |
|
| 26 | { |
|
| 27 | $lines = static::getModule()->readArray($path); |
|
| 28 | $matterLines = $this->readQuotedLines($lines, '/^{#/', '/#}$/'); |
|
| 29 | if (empty($matterLines)) { |
|
| 30 | $data = []; |
|
| 31 | $text = $lines; |
|
| 32 | } else { |
|
| 33 | $data = $this->readFrontMatter($matterLines); |
|
| 34 | $text = array_slice($lines, count($matterLines)); |
|
| 35 | } |
|
| 36 | ||
| 37 | return [$data, implode("\n", $text)]; |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 99-112 (lines=14) @@ | ||
| 96 | return new $class($path, $storage); |
|
| 97 | } |
|
| 98 | ||
| 99 | public function extractData($path) |
|
| 100 | { |
|
| 101 | $lines = $this->storage->readArray($path); |
|
| 102 | $yaml = $this->readQuotedLines($lines, '/^---$/', '/^---$/'); |
|
| 103 | if (empty($yaml)) { |
|
| 104 | $data = []; |
|
| 105 | $text = $lines; |
|
| 106 | } else { |
|
| 107 | $data = $this->readYaml($yaml); |
|
| 108 | $text = array_slice($lines, count($yaml)); |
|
| 109 | } |
|
| 110 | ||
| 111 | return [$data, implode("\n", $text)]; |
|
| 112 | } |
|
| 113 | ||
| 114 | public function readFrontMatter($lines) |
|
| 115 | { |
|