ExpressionEngine Docs

Template Language

ExpressionEngine has its own template language which allows you to retrieve and display information dynamically.

Single Variables

Single Variables output a single piece of content. Some variables are intended to be used within Template Tags (as in the examples below), others are available globally wherever you would like to put them in your templates.

For example, to show the username of the logged-in user, you would use:


Variable Pairs

Variable pairs expose several single variables between them to allow for more granular access to the data than their single variable counterparts:

    File name: {file_name}
    File extension: {extension}
    Url: {url}

Module and Plugin Tags

To retrieve and show the information contained in your Modules and Add-Ons you will use the {exp: tag. They most frequently come in pairs that loop over rows of content. The template chunk between them will be repeated for each row they represent, and the variables between them will be replaced with the values of each row of content. Here is what a typical template tag looks like:


The above code tells your ExpressionEngine template to retrieve data from the channel entries module.

Nested Plugins

It is possible to nest plugins in order for content to be affected by more than one plugin. For example, you can do this:

{exp:word_limit total="35"}
        some content

By default, ExpressionEngine will process the innermost plugin first, then the next plugin, and so on until all the plugins wrapping a given piece of content have been parsed. In the above example, the content is XML Encoded first and then the result of that is limited to 35 words.


Many ExpressionEngine tags and variables can accept parameters. Parameters are used to pass information on how the tag or variable behaves. They look just like HTML parameters, with a name and a value:

{exp:channel:entries channel="news" limit="5"}


Most template variables can be modified for common formatting and output needs without requiring any plugins. For instance, making user-submitted content safe for use in a <meta> tag attribute, limiting to a certain number of characters, displaying currency, or as JSON to create structured data for SEO.

Here’s a modifier which gets the length of a string:

{!-- Outputs: 217 --}

A full list of the available modifiers can be found here.

Embedded Templates

A Template often represents an entire page of your site. However, you can also use Templates inside of other Templates in order to re-use page components. A good use for an embedded template would be a header or footer. Here’s the basic syntax:


More Information: Template Embeds

Template Layouts

In addition to embedding templates within each other, you can also create shared layouts for your templates. This is a more advanced concept explained in the Layouts page.

You can wrap a template in a layout to reuse wrapping code between several templates:


More Information: Template Layouts


Anything inside of a comment tag, including other template tags, will be ignored by the template. Comments are never shown when a template is displayed.

{!--  Show the next blog post if it exists.  --}


Conditionals allow you to add logic to your templates:

{if logged_in}Welcome back.{/if}

{if (age + 5) == 100}Five years to go!{/if}

{if age == 30 AND username == 'Bob'}Welcome back, Bob. 30 is the new 20.{/if}
  You are 30!
{if:elseif username == 'Bob'}
  You are Bob!
  You're not 30 or Bob. That's all we know.

More information: Conditional Tags

{ee:u} Read the Primer On Simple Conditionals article on ExpressionEngine University to learn more about using conditionals in ExpressionEngine.

Changing Parsing Order

You may change the parsing order of plugins and instruct ExpressionEngine to parse an outer plugin first. This is done by adding a parse=”inward” parameter to the plugin opening tag. Using that parameter will tell EE to parse that plugin before parsing any plugins inside of it:



Here are some examples to help illustrate the parsing order.:

{exp:rss_parser url="" limit="5" parse="inward"}
        <a href="{item_link}">{item_title}</a><br />
        {exp:word_limit total="20"}
        {/exp:word_limit}<br />

With the above, the RSS plugin will be parsed first. This will allow the content of the {content} variable to be available to the other, nested plugin: “word_limit”.

Here is a much more complicated example that demonstrates both parsing orders in action.:

{exp:rss_parser url="" limit="5" parse="inward"}
        <li><a href="{item_link}">{item_title}</a><br />
                {exp:word_limit total="35"}

The outer RSS plugin has the parameter set to parse inward, so it is parsed first. This makes the {content} variable’s content available to the other plugins. Next, is the “word_limit” plugin. However, since by default EE parses plugins outward, the “xml_encode” plugin is parsed first and then “word_limit” after it. In this way, “word_limit” will never erase the closing tag for the “xml_encode” plugin.