> For the complete documentation index, see [llms.txt](https://squirrelly.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://squirrelly.gitbook.io/docs/api/render.md).

# Render

## Syntax

```javascript
Sqrl.Render(template, options)
//If template is a function, returns the result of template(options, Sqrl)
//If template is a string, it will Compile the string
//and then return compiled(options, Sqrl)
```

{% hint style="info" %}
Rendering a function is usually better for performance, since Squirrelly doesn't have to re-compile the template each time it Renders.
{% endhint %}

{% hint style="info" %}
Caching is available. Set `options.$cache` to `true`, and set `options.$name` to some string value so Squirrelly can cache the resulting function.
{% endhint %}

## Examples

### Rendering a string

```
var myTemplate = `
My favorite template engine is {{fav}}
`
Sqrl.Render(myTemplate, {
    fav: "Squirrelly!"
})
//Returns "My favorite template engine is Squirrelly!"
```

### Rendering a function

```
var myTemplate = `
My favorite template engine is {{fav}}
`
var compiledTemplate = Sqrl.Compile(myTemplate)
Sqrl.Render(compiledTemplate, {
    fav: "Squirrelly!"
})
//Returns "My favorite template engine is Squirrelly!"
```
