> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# fromTemplate

APISummary
输入 Lynx 模板二进制内容，返回解析后的 `TemplateBundle` 对象。

## 语法

### Android

```java
public static TemplateBundle fromTemplate(byte[] template);
```

#### 参数说明

- `template`: 模板二进制内容。

#### 返回值

- `TemplateBundle` 对象。

:::note

- 当输入的 `template` 为 `null` 时，此方法直接返回 `null`。
- 当输入的 `template` 不是正确的 `Lynx` 模板数据时，将返回一个无效的 `TemplateBundle`。

:::

### iOS

```objc
- (instancetype _Nullable)initWithTemplate:(nonnull NSData *)tem;
```

#### 参数说明

- `tem`: 模板二进制内容。

#### 返回值

- `TemplateBundle` 对象。

:::note

- 当输入的 `tem` 不是正确的 `Lynx` 模板数据或为 `nil` 时，将返回一个无效的 `TemplateBundle`。

:::

### Harmony

```typescript
public static async fromTemplate(template: ArrayBuffer): Promise<TemplateBundle>;
```

#### 参数说明

- `template`: 模板二进制内容。

#### 返回值

- Promise 形式的 TemplateBundle。

## 兼容性

**Compatibility Table**

**Query:** `lynx-native-api.template-bundle.from-template`

[Source](https://github.com/lynx-family/lynx-website/tree/main/packages/lynx-compat-data/lynx-native-api/template-bundle/from-template.json)

| Feature | Android | HarmonyOS | iOS | macOS | Windows | Web |
| --- | --- | --- | --- | --- | --- | --- |
| from-template | Yes (2.8) | Yes (3.4) | Yes (2.8) | No | No | No |

**`from-template`**

Input Lynx template binary content and return the parsed TemplateBundle object.

**Specifications:**

