---
title: "Class TemplateExtensions"
slug: "web-sdk--stylelabs.m.sdk.webclient.http.templateextensions"
abstract: ""
---
# Class TemplateExtensions

Contains extension method for handling url templates.

## Inheritance

object

TemplateExtensions

## Namespace: StylelabsStylelabs.MSdkWebClientHttp

## Assembly: Stylelabs.M.Sdk.WebClient.dll

## Syntax

```csharp
public static class TemplateExtensions
```

## Methods

### Bind(Link, IDictionary<string, string>)

Parses the link's template and applies the specified values to it.

#### Declaration

```csharp
public static string Bind(this Link link, IDictionary<string, string> values)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Link](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.base.web.api.models.link.html) | link | The link to parse. |
| IDictionary<, >stringstring | values | The values of the templatized parameters. |

#### Returns

| Type | Description |
| --- | --- |
| string | The link's template with it's parameters replaced by the specified values. |

### Bind(Link, object)

Parses the link's template and applies the specified values to it.

#### Declaration

```csharp
public static string Bind(this Link link, object values = null)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Link](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.base.web.api.models.link.html) | link | The link to parse. |
| object | values | The values of the templatized parameters. |

#### Returns

| Type | Description |
| --- | --- |
| string | The link's template with it's parameters replaced by the specified values. |

### GetVariableValue(Link, Link, string)

Extracts the value of the specified `variable` from the `link` based on a given `template`.

#### Declaration

```csharp
public static string GetVariableValue(this Link link, Link template, string variable)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| [Link](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.base.web.api.models.link.html) | link | The link to extract the variable from. |
| [Link](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.base.web.api.models.link.html) | template | The template that defines the variables. |
| string | variable | The name of the variable to extract. |

#### Returns

| Type | Description |
| --- | --- |
| string | The value of the variable or null if the variable could not be found. |

### GetVariableValue(Uri, Link, string)

Extracts the value of the specified `variable` from the `uri` based on a given `template`.

#### Declaration

```csharp
public static string GetVariableValue(this Uri uri, Link template, string variable)
```

#### Parameters

| Type | Name | Description |
| --- | --- | --- |
| Uri | uri | The uri to extract the variable from. |
| [Link](https://doc.sitecore.com/ch/en/developers/api-reference/web-sdk--stylelabs.m.base.web.api.models.link.html) | template | The template that defines the variables. |
| string | variable | The name of the variable to extract. |

#### Returns

| Type | Description |
| --- | --- |
| string | The value of the variable or null if the variable could not be found. |
