/** * Parses the given input * * @param string $input * * @return LexedTemplate * @throws HtplException */ public static function parse($input) { try { $instance = new self($input); $lexedTags = $instance->getOutput(); } catch (HtplException $e) { throw new HtplException(sprintf('Unable to parse the template.' . "\n"), 0, $e); } return new LexedTemplate($lexedTags, $input); }
/** * Parses the given input * * @param string $input * @param Htpl $htpl * @param bool $outputVar * * @return string Parse result. * @throws HtplException */ public static function parse($input, Htpl $htpl, $outputVar = true) { // break template into lines $lines = explode("\n", $input); foreach ($lines as $l => $line) { try { $instance = new self($line, $htpl); $lines[$l] = $instance->getOutput($outputVar); } catch (HtplException $e) { throw new HtplException(sprintf('Unable to parse the template at line %s. ', $l) . $e->getMessage()); } } return implode("\n", $lines); }