19 declare(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();
getAsyncUrl()
Returns an endpoint where the clientside input can submit it's value to and receive the current previ...
sendResponse(string $html)
render(string $markdown_text)
Returns the rendered preview of the given string.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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.
getParameterName()
Returns the name of the $_POST variable the asynchronous input submits to.
renderAsync()
Sends a JSON-response with the rendered preview of the submitted input.