Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Only replace a get 'route' request if the route it is looking for exists
  • Loading branch information
kolber committed Dec 13, 2009
1 parent ca31ca0 commit 3f3bc47
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/parsers/template-parser.inc.php
Expand Up @@ -36,12 +36,16 @@ static function parse($data, $template) {
static function parse_get(&$data, $template) {
# match any gets
preg_match('/get[\s]+?["\']\/?(.*?)\/?["\']/', $template, $template_parts);
# strip out the get line
$template = str_replace($template_parts[0], '', $template);
# turn route into file path
# turn route into file path
$file_path = Helpers::url_to_file_path($template_parts[1]);
# set data object to match file path
$data = AssetFactory::get($file_path);
# if the route exists...
if(file_exists($file_path)) {
# strip out the get line
$template = str_replace($template_parts[0], '', $template);
# set data object to match file path
$data = AssetFactory::get($file_path);
}

return $template;
}

Expand Down

0 comments on commit 3f3bc47

Please sign in to comment.