Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/php/web/frontend/View.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/php/web/frontend/unittest/ViewTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down