19declare(strict_types=1);
44 $this->
ctrl = $DIC->ctrl();
45 $this->
http = $DIC->http();
50 if (!$this->
ctrl->isAsynch() && self::CMD_RENDER_ASYNC !== $this->ctrl->getCmd()) {
51 $this->
http->saveResponse(
54 ->withBody(Streams::ofString(
'Whoops, something went wrong!'))
58 $this->
http->sendResponse();
67 return $this->
ctrl->getLinkTargetByClass(
69 self::CMD_RENDER_ASYNC,
77 return 'raw_markdown';
84 if (!$this->
http->wrapper()->post()->has($parameter_name)) {
88 $raw_markdown = $this->
http->wrapper()->post()->retrieve(
96 public function render(
string $markdown_text): string
98 return $this->
refinery->string()->markdown()->toHTML()->transform($markdown_text);
103 $this->
http->saveResponse(
104 $this->
http->response()->withBody(Streams::ofString($html))
107 $this->
http->sendResponse();
108 $this->
http->close();
The scope of this class is split ilias-conform URI's into components.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
renderAsync()
Sends a JSON-response with the rendered preview of the submitted input.
getAsyncUrl()
Returns an endpoint where the clientside input can submit it's value to and receive the current previ...
getParameterName()
Returns the name of the $_POST variable the asynchronous input submits to.
sendResponse(string $html)
render(string $markdown_text)
Returns the rendered preview of the given string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.