# Reference

TTML provides two ways to reference files: `import` and `include`.

## Import

`import` can use the `template` defined by the object file in this file, such as:

A `template` called `item` is defined in item.ttml:

```html
<template name="item">
    <text>{{text}}</text>
</template>
````

With item.ttml referenced in index.ttml, the `item` template can be used:

```html
<import src="item.ttml"/>
<template is="item" data="{{text: 'forbar'}}"/>
````

### Import scope

`import` has its scope, i.e. it will only `import` the `template` defined in the object file, but not the `template` of the `import` object file.

**For example: C import B, B import A, the template defined by B can be used in C, and the template defined by A can be used in B, but C cannot use the template defined by A. **

```html
<template name="A"> <text> A template </text></template>

<import src="a.ttml"/>
<template name="B">
    <text> B template </text>
</template>

<import src="b.ttml"/>
<template is="A"/>

<template is="B"/>
````

## Include

Use include to import the entire code of the target file except `<template/>`, which is equivalent to copying it to the include location, such as:

```html
<include src="header.ttml"/>
<view><text>body</text></view>
<include src="footer.ttml"/>

<view><text>header</text></view>

<view><text>footer</text></view>
````
