# @Render Decorator

{% hint style="info" %}
This article requires knowledge of [Controllers](https://mandarineframework.gitbook.io/mandarine-ts/mandarine-mvc/controllers) & [HTTP Handlers](https://mandarineframework.gitbook.io/mandarine-ts/mandarine-mvc/controllers/http-handlers)
{% endhint %}

## Main

In order to make an endpoint "*renderable*", it is necessary to decorate your *HTTP Handler* with the `@Render` decorator. The `@Render` decorator will tell Mandarine's MVC core that such endpoint is expecting to be rendered on the client's browser and thus Mandarine's MVC core will be expecting a *renderable* content.

## Usage

**Syntax:**

See [*Mandarine.MandarineMVC.TemplateEngine.RenderingOptions*](https://doc.deno.land/https/raw.githubusercontent.com/mandarineorg/mandarinets/master/mvc-framework/mandarine-mvc.ns.ts#MandarineMvc.TemplateEngine.RenderingOptions)

See [*Mandarine.MandarineMVC.TemplateEngine.Engines*](https://doc.deno.land/https/raw.githubusercontent.com/mandarineorg/mandarinets/master/mvc-framework/mandarine-mvc.ns.ts#MandarineMvc.TemplateEngine.Engines)

```typescript
@Render(template: string, 
options?: Mandarine.MandarineMVC.TemplateEngine.RenderingOptions, 
engine?: Mandarine.MandarineMVC.TemplateEngine.Engines)
```

* `template`
  * Used to specify the path of your template **inside** your template's directory. This means, you **must not** specify the whole path as it will be resolved.
  * Used to specify the content of the template instead of using a file.
    * If a manual template is used, *Mandarine.MandarineMVC.TemplateEngine.RenderingOptions.**manual** must be* *true*
* `options`
  * Used to specify the behavior of loading the template.&#x20;
    * `manual` If set to true, template is not considered a file but a string content.
* engine
  * Engine to be used when rendering the template

Example

```typescript
./src/main/resources/templates/index-template.html

<h2>Hello Bill! Nice to see you here again</h2>
```

{% tabs %}
{% tab title="Controller" %}

```typescript
myfile.ts

import { Controller, GET, Render, MandarineCore } from "https://deno.land/x/mandarinets/mod.ts";

@Controller()
export class MyController {

    @GET('/path-template')
    @Render('index-template.html')
    public httpHandler() {
    }
    
    @GET('/manual-template')
    @Render(`<h2>This is a manual template</h2>`, { manual: true })
    public httpHandler2() {
    }
    
}

new MandarineCore().MVC().run();
```

{% endtab %}

{% tab title="Result" %}
![# http://127.0.0.1:8080/path-template](https://62970137-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HNG2ebFcjvBcN6EEf%2F-M8Mcm7FJ9GHjkGir4tB%2F-M8NH1zcXZw9uDFJEU3a%2FScreen%20Shot%202020-05-27%20at%206.33.03%20PM.png?alt=media\&token=13cbc6ba-d8dd-4677-8919-711d01ab19d6)

![# http://127.0.0.1:8080/manual-template](https://62970137-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8HNG2ebFcjvBcN6EEf%2F-M8Mcm7FJ9GHjkGir4tB%2F-M8NH9eMxoHXGMoujIfZ%2FScreen%20Shot%202020-05-27%20at%206.35.54%20PM.png?alt=media\&token=bcb834f4-64a9-415c-a3ad-3b33fecf4266)
{% endtab %}
{% endtabs %}
