# Template Tags

Anywhere in your template you can reference an early parsed global variable for each feature flag to determine if content shouldbe shown. In this example if the new\_product feature flag is enabled and active, then the text will be rendered.

```html
{if feature:new_product}
    <p>Show me the money!</p>
{/if}
```

If a Feature Flag field is added to a channel you *do not* need to modify your template to show or hide the entry content. For example, the following custom field is added to a channel, and when editing an entry you will see in plain text what it wants to do. If the last dropdown option is set to "Hide" this entry, then the `channel:entries` tag will automatically remove the entry from the result loop if the `new_product` feature flag is enabled and active. If it is set to show, then it will only display the entry in the `channel:entries` tag when the `new_product` feature flag is enabled. If it is not enabled, it will skip the entry when looping over the `channel:entries` tag results.

<figure><img src="/files/bBfRnH3Kfz7Y0Pgy47zl" alt=""><figcaption></figcaption></figure>

A Feature Flags field when used as a channel field is the only time you won't be required to add a template conditional tag to show or hide your content.

```html
{exp:channel:entries channel="pages"}
    <h1>{title}</h1>
{/exp:channel:entries}
```

If you add a Feature Flags field to Bloqs or Grid you *will* need to add a conditional to your template tag for this to work. For example we have 2 Conditional Display bloqs below. The first will display itself and it's child bloqs if the new\_product feature flag is enabled and active. The second will not display itself or it's children if the feature flag is enabled and active.

<figure><img src="/files/QqP6TfIFAATZeOgQCKrR" alt=""><figcaption></figcaption></figure>

```html
{exp:channel:entries channel="pages"}
    <h1>{title}</h1>
    {bloqs}
        {conditional_display}
            {if display_content}
                <!-- Since all the other bloqs are children of the 
                Conditional Display bloq will display based on the condition
                of the Display Content field. -->
                {bloqs:children}
            {/if}
        {/conditional_display}

        {related_entries}
            ...
        {/related_entries}
        
        {asset}
            ...
        {/asset}
    {/bloqs}
    
    {grid}
        {if grid:display_content}
            <!-- This text will display if the 
            new_product flag is enabled and active. -->
        {/if}
    {/grid}
    
{/exp:channel:entries}
```

### Using Feature Flags in JavaScript code

You can reference a feature flag in JavaScript if you add the {feature\_flags:all} tag to your document, which will output JSON encoded string of the flags available, and their current status. For example:

```json
{
    new_product: true,
    ab_test_carousel: false
}
```


---

# 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.boldminded.com/feature-flags/docs/template-tags.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.
