diff --git a/src/main/php/web/frontend/View.class.php b/src/main/php/web/frontend/View.class.php index 17718a9..74a5a0d 100755 --- a/src/main/php/web/frontend/View.class.php +++ b/src/main/php/web/frontend/View.class.php @@ -18,11 +18,13 @@ private function __construct($template) { /** * Sets template to use * - * @param string $template + * @param string $name * @return self */ - public static function named($template) { + public static function named($name) { + sscanf($name, "%[^#]#%[^\r]", $template, $fragment); $self= new self($template); + $self->fragment= $fragment; $self->headers['Content-Type']= 'text/html; charset='.\xp::ENCODING; return $self; } diff --git a/src/test/php/web/frontend/unittest/ViewTest.class.php b/src/test/php/web/frontend/unittest/ViewTest.class.php index eeebda9..d8ca4a1 100755 --- a/src/test/php/web/frontend/unittest/ViewTest.class.php +++ b/src/test/php/web/frontend/unittest/ViewTest.class.php @@ -20,6 +20,13 @@ public function fragment() { Assert::equals('inline', View::named('test')->fragment('inline')->fragment); } + #[Test] + public function template_and_fragment_separated_with_hash() { + $view= View::named('test#inline'); + Assert::equals('test', $view->template); + Assert::equals('inline', $view->fragment); + } + #[Test] public function default_status() { Assert::equals(200, View::named('test')->status);