/Phrozn/Twig/Loader/String.php
PHP | 50 lines | 15 code | 2 blank | 33 comment | 1 complexity | b42e7100117c0e2a3472ac32ac5108f4 MD5 | raw file
Possible License(s): Apache-2.0
- <?php
- /**
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @category Phrozn
- * @package Phrozn\Twig
- * @author Victor Farazdagi
- * @license http://www.apache.org/licenses/LICENSE-2.0
- */
- namespace Phrozn\Twig\Loader;
- /**
- * Twig String Loader
- *
- * @category Phrozn
- * @package Phrozn\Processor
- * @author Victor Farazdagi
- */
- class String
- extends \Twig_Loader_String
- implements \Twig_LoaderInterface
- {
- /**
- * Gets the source code of a template, given its name.
- *
- * @param string $name Template content
- *
- * @return string The template source code
- */
- public function getSource($name)
- {
- // strip front-matter
- $parts = preg_split('/[\n]*[-]{3}[\n]/', $name, 2);
- if (count($parts) === 2) {
- return ltrim($parts[1]);
- }
- return $name;
- }
- }