# HasTemplate

> Provides an immutable API for managing the template string.

[API reference](/docs/api/index.md) › [HTML Mixin](/docs/extensions/html-mixin/reference/index.md) › HasTemplate

| trait | `UIAwesome\Html\Mixin\HasTemplate` |
| --- | --- |
| Source | [`src/HasTemplate.php`](https://github.com/ui-awesome/html-mixin/blob/main/src/HasTemplate.php#L10) |

Used by 2 types:

- [`UIAwesome\Html\Core\Element\BaseInline`](/docs/extensions/html-core/reference/element/baseinline/index.md)
- [`UIAwesome\Html\Core\Element\BaseInput`](/docs/extensions/html-core/reference/element/baseinput/index.md)

Provides an immutable API for managing the template string.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-template"></span>`$template` protected | `string` | Template string used for constructing the HTML tag. Default: `''`. | `HasTemplate` |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`getTemplate()`](#method-getTemplate) | Returns the template assigned to the element. | `HasTemplate` |
| [`template()`](#method-template) | Sets the template string for the element. | `HasTemplate` |

## Method details

### getTemplate() <span id="method-getTemplate"></span>

```php
public function getTemplate(): string
```

Returns the template assigned to the element.

**Returns**

`string`: Template value assigned to the element. Never `null`.

### template() <span id="method-template"></span>

```php
public function template(string $value): static
```

Sets the template string for the element.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | Template string to set for the element. |

**Returns**

`static`: New instance with the updated `template` value.