> For the complete documentation index, see [llms.txt](https://docs.wem.io/platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wem.io/platform/template-editor/miscellaneous/script.md).

# Script

## ![](https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FSClK9a1tK7jGBWbVMVTs%2FScript.png?alt=media\&token=4d5cba56-4445-4e3f-8fa1-cee03cd05d41) Introduction

{% hint style="info" %}
You can find more information about the WEMScript in the specific pages. There is a page about the [WEMScript for Custom HTML](/platform/wemreference/wemscript-for-custom-html.md), and [WEMScript for Widgets](/platform/wemreference/wem-widgets/wemscript-for-widgets.md).
{% endhint %}

With the Script widget you can add HTML code and other script code (like JavaScript) to the Template Editor.

**Note**: when you use the Script widget, it is possible to overwrite (intended or unintended) the Design Template settings.

Drag and drop the Script widget to the Template Editor and the box below appears.

![You can enter your HTML script here](https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2Fa2YAiIjYDbJxLyNizKb3%2FtemplateEditor-misc.Script.png?alt=media\&token=87b6c3d8-1d07-4b5c-be70-7bca46ad7899)

## Illustration&#x20;

Let's build upon the EMS use case from where we had left at in the page for 'Nested Templates'. We had built an interaction template with a Tabbar consisting of two tabs and Datagrids inside Conditionals that should be displayed based on the tab clicked. The 'Projects' tab at run-time was something like the below.&#x20;

<figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2F29A2LrwXjQSP6QUOjwQq%2FScreenshot%202023-01-30%20at%2013.46.02.jpg?alt=media&amp;token=d5af9b3f-a738-40b2-9881-e1aeda79856e" alt=""><figcaption></figcaption></figure>

Let's say that we now have this requirement - the total number of projects should be shown below the table, in red font.&#x20;

1. Open the 'Projects' Template Fragement.&#x20;

   <figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FG3xOiw67WxIVZjrBXd1B%2FScreenshot%202023-01-30%20at%2013.51.33.jpg?alt=media&amp;token=044f93fa-4d64-456f-96ac-d24e04953f12" alt=""><figcaption></figcaption></figure>
2. Insert a Label below the Table, which would show a count of the number of projects.&#x20;

   <figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FmSxbOadzQoGLMlhDfZCc%2FScreenshot%202023-01-30%20at%2013.59.33.jpg?alt=media&amp;token=b044db1a-732c-4613-96dd-6a82ac8480a6" alt=""><figcaption></figcaption></figure>
3. Click and drag the 'Script' icon and place it above the Label.&#x20;

   <figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FntXnbnG8bTIpqsWV6lgJ%2FScreenshot%202023-01-30%20at%2014.01.55.jpg?alt=media&amp;token=7827cbce-c49a-4152-877b-a6c3dfbb00a9" alt=""><figcaption></figcaption></figure>
4. Compose your Script and then click on 'Validate'.

   <figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2F2ytF7LPzrdj8DsK7OXQa%2FScreenshot%202023-01-30%20at%2014.08.00.jpg?alt=media&amp;token=ae560316-d663-44b3-9acd-0db1a477ccb1" alt=""><figcaption></figcaption></figure>
5. Repeat steps 3 and 4 for closing the script, but below the Label.&#x20;

   <figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2F9r6xkiKmFO0ei1C2FpW9%2FScreenshot%202023-01-30%20at%2014.09.22.jpg?alt=media&amp;token=7d8d7ca3-43d3-4ba6-8f9f-ac5431bcfbbb" alt=""><figcaption></figcaption></figure>
6. Click on 'Save' in the Template Editor. When you preview, you will now see the Label in red below the Table.&#x20;

   <figure><img src="https://1449034948-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L_NpOsk0sjotPXNy29Q%2Fuploads%2FXwOBZ097tDo6ADsXzhmx%2FScreenshot%202023-01-30%20at%2014.10.55.jpg?alt=media&amp;token=d61c6393-ff58-476f-b61d-13c694ff86a8" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.wem.io/platform/template-editor/miscellaneous/script.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
