Skip to content

Commit

Permalink
修复:模板包含错误
Browse files Browse the repository at this point in the history
  • Loading branch information
dxkite committed Mar 20, 2017
1 parent 2f953f6 commit affb56e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions system/src/suda/template/Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,9 @@ protected function parseEndwhile()
}

// include
protected function parseInclude($exp, array $includes=[])
protected function parseInclude($exp)
{
preg_match('/^\(([\'"])(.+)(?1)/', $exp, $match);
return "<?php suda\\template\\Manager::include('{$match[2]}',\$v->_getVar()) ?>";
return "<?php suda\\template\\Manager::include{$exp} ?>";
}

protected function parseU($exp)
Expand Down Expand Up @@ -153,7 +152,7 @@ public static function echo($something)
protected function parseStartInsert($exp)
{
preg_match('/\((.+)\)/', $exp, $v);
return '<?php suda\\template\\Manager::hook('.$v[1].',function ($v) { ?>';
return '<?php suda\\template\\Manager::hook('.$v[1].',function () { ?>';
}

protected function parseEndInsert()
Expand All @@ -163,7 +162,7 @@ protected function parseEndInsert()
protected function parseInsert($exp)
{
preg_match('/^\(([\'"])(.+)(?1)/', $exp, $match);
return "<?php suda\\template\\Manager::exec('{$match[2]}',\$v) ?>";
return "<?php suda\\template\\Manager::exec('{$match[2]}') ?>";
}

// 错误报错
Expand Down
4 changes: 2 additions & 2 deletions system/src/suda/template/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ public static function hook(string $name, $callback)
self::$hooks[$name][]=new \suda\tool\Command($callback);
}

public static function exec(string $name, $var)
public static function exec(string $name)
{
if (isset(self::$hooks[$name])) {
foreach (self::$hooks[$name] as $hook) {
$hook->exec([$var]);
$hook->exec();
}
}
}
Expand Down

0 comments on commit affb56e

Please sign in to comment.