# Accessing partial variables in template

**URL:** <https://discourse.gohugo.io/t/accessing-partial-variables-in-template/14123>\
**Category:** support\
**Created:** [September 9, 2018, 8:16am UTC](https://discourse.gohugo.io/t/accessing-partial-variables-in-template/14123 "2018-09-09T08:16:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![UtkarshVerma](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/utkarshverma/32/11273_2.png) [@UtkarshVerma](https://discourse.gohugo.io/u/UtkarshVerma)\
**Post date:** [September 9, 2018, 8:16am UTC](https://discourse.gohugo.io/t/accessing-partial-variables-in-template/14123/1 "2018-09-09T08:16:46Z")

</div>

I want to be able to use called partial’s variables in my template. Is there any way to do it?  
For example, I have a `pagination.html` partial which only initializes `$paginator`. Now I want to be able to call `$paginator` after including `pagination.html` in my template using `{{ partial "pagination.html" . }}`.

---

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [September 9, 2018, 12:31pm UTC](https://discourse.gohugo.io/t/accessing-partial-variables-in-template/14123/2 "2018-09-09T12:31:34Z")

</div>

You need to attach this pagination on your page context using `.Scratch`. Then as you are passing this page context to your `pagination.html` partial, you will be able to get it from there.

```auto
{{ .Scratch.Set "pagination" $paginator }}
{{ partial "pagination.html" . }}

```

Then from `layouts/partial/pagination.html`

```auto
{{ .Scratch.Get "pagination" }}

```

---

<div class="post-metadata">

**Author:** ![regis](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/regis/32/4958_2.png) [@regis](https://discourse.gohugo.io/u/regis)\
**Post date:** [September 9, 2018, 12:34pm UTC](https://discourse.gohugo.io/t/accessing-partial-variables-in-template/14123/3 "2018-09-09T12:34:07Z")

</div>

Realized you want to do that in the reversed order. But it’s the same. Use `.Scratch.Set` from within the partial, and then when using the page context outside the partial, you’ll be able to do a `.Scratch.Get "pagination`.
