diff --git a/developer_manual/basics/controllers.rst b/developer_manual/basics/controllers.rst index 3ec000219..c6654be9d 100644 --- a/developer_manual/basics/controllers.rst +++ b/developer_manual/basics/controllers.rst @@ -347,9 +347,43 @@ This can be in the form of a Response subclass or in the form of a value that ca HTML-based Responses -------------------- +.. _controller_template: + Templates ^^^^^^^^^ +A :doc:`template ` can be rendered by returning a TemplateResponse. A TemplateResponse takes the following parameters: + +* **appName**: tells the template engine in which app the template should be located +* **templateName**: the name of the template inside the templates/ folder without the .php extension +* **parameters**: optional array parameters that are available in the template through $_, e.g.:: + + array('key' => 'something') + + can be accessed through:: + + $_['key'] + +* **renderAs**: defaults to *user*, tells Nextcloud if it should include it in the web interface, or in case *blank* is passed solely render the template + +.. code-block:: php + + 'hi'); + return new TemplateResponse($this->appName, $templateName, $parameters); + } + + } + Public page templates ^^^^^^^^^^^^^^^^^^^^^ @@ -532,41 +566,6 @@ Because returning values works fine in case of a success but not in case of fail } -Templates -^^^^^^^^^ - -A :doc:`template ` can be rendered by returning a TemplateResponse. A TemplateResponse takes the following parameters: - -* **appName**: tells the template engine in which app the template should be located -* **templateName**: the name of the template inside the templates/ folder without the .php extension -* **parameters**: optional array parameters that are available in the template through $_, e.g.:: - - array('key' => 'something') - - can be accessed through:: - - $_['key'] - -* **renderAs**: defaults to *user*, tells Nextcloud if it should include it in the web interface, or in case *blank* is passed solely render the template - -.. code-block:: php - - 'hi'); - return new TemplateResponse($this->appName, $templateName, $parameters); - } - - } - Public page templates ^^^^^^^^^^^^^^^^^^^^^