Section: Generating plain text
« Generating HTML5 content | ^ Responses: generating content | Generating XML content » |
To create a jResponseText
object, pass 'text' as argument to getResponse()
method in your controller's action.
jResponseText has a content
property which should be assigned before output.
function myaction(){
$resp = $this->getResponse('text');
$resp->content = 'my text';
return $resp;
}
jResponseText returns "text/plain" Mime-Type by default, and uses jelix configuration default charset.
jResponseText inherits from jResponse
, allowing you to modify HTTP headers such
as Mime-Type or charset as well.
jResponseText can be used as a base to create other formats with text-data, for example to craft a CSV response.