# AUR0702

### **Error message**

Template compilation error: attribute "{{0}}" is invalid on element surrogate.

### **Parameters**

1. `attribute`: The name of the invalid attribute found on the surrogate `<template>` tag.

### Error explanation

This error occurs when the template compiler finds certain disallowed attributes on the root `<template>` tag of a custom element definition. These attributes, including `id`, `name`, `au-slot`, and `as-element`, cannot be applied directly to the surrogate `<template>` itself.

### Common causes

* Adding `id="my-id"`, `name="my-name"`, `au-slot="some-slot"`, or `as-element` directly to the `<template>` tag of a component's HTML file.

### How to fix

* Remove the disallowed attribute from the root `<template>` tag.
* If you need an `id` or other attributes on the component's host element, they should be applied where the component is used, not within its definition's `<template>` tag.
* `au-slot` is used on elements *inside* a component's template to project content *into* that component when it's used elsewhere. It doesn't belong on the root `<template>`.
* `as-element` is valid on regular markup when you want the compiler to treat an element as a specific custom element, but it cannot appear on the surrogate `<template>`. Move it onto the real element you want to alias, or use `as-custom-element` on nested `<template>` declarations when defining local elements.

### Example of Incorrect Usage:

```html
<!-- my-component.html -->
<template id="this-is-wrong"> <!-- Error: id is invalid on surrogate -->
  <div>Hello</div>
</template>

<template au-slot="also-wrong"> <!-- Error: au-slot is invalid on surrogate -->
  <div>World</div>
</template>
```

### Example of Correct Usage:

```html
<!-- my-component.html -->
<template> <!-- No invalid attributes here -->
  <div>Hello</div>
  <slot></slot> <!-- Use slot inside the template -->
</template>

<!-- Usage in another component -->
<my-component id="host-id-is-ok"> <!-- Apply id where the component is used -->
  <div au-slot> <!-- Use au-slot on the projected content -->
    Projected Content
  </div>
</my-component>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.aurelia.io/developer-guides/error-messages/0088-to-0723/aur0702.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
