Feed Parser Templates

This section describes how to format Feed Variables and Entry Variables in a Feed Parser template.

Variables

Feed Parser extracts content from a feed URL into Feed Variables and Entry Variables.

Feed Variables provide metadata for the feed. You can include Feed Variables directly in the Feed Parser template editor.

Syntax:

{{feed:<feed-variable>}}

Entry Variables provide metadata for each feed entry. To include entry variables in the Feed Parser template editor, you must enclose the variables in an Entry Loop. An Entry Loop repeats the variables that you set for each entry.

Syntax:

{{entry_loop}}
    {{<entry-variable>}}
{{/entry_loop}}

Example: A Feed Variable and Entry Variables in a Feed Parser Template

This template displays the feed title, and the title, description, and publication date for each feed entry. The content of the entry loop repeats for each feed entry.

{{feed:title}}

{{entry_loop}}
    {{title}}
    {{description}}
    {{pudDate}}
{{/entry_loop}}

Entry Loop Parameters

The following parameters enable you to skip, limit, and apply filters to the content in your entry loop:

  • skip

    Specifies the number of feed entries to skip before the loop starts.

  • limit

    Specifies the maximum number of feed entries to display.

  • filter-variable

    Filters feed entries by the entry variable that you specify. Requires filter-value.

  • filter-value

    Filters feed entries by the value that you specify. Requires filter-variable.

  • filter-type

    Filters items by type which you specify.

    • equalsIgnoreCase

      Returns lower and uppercase items.

    • startsWith

      Returns items that begin with the filter value.

    • contains

      Returns items that contain the filter value.

    • matches

      Returns items that match the filter value.

Examples:

  • This entry loop uses parameters to return the titles for all entries in the Features category:
    {{entry_loop filter-variable="category" filter-value="Features"}}
        {{title}}
    {/entry_loop}}                
  • This entry loop uses parameters to return the titles for all entries that start with the text "How to", and limits the list to five entries.
    {{entry_loop filter-variable="title" filter-value="How to" filter-type="startsWith" limit="5"}}
        {{title}}
    {{/entry_loop}}

Formatting Expressions

You can apply formatting expressions to modify the values of entry variables. For example, you can use the trim expression to limit the value of the title Entry Variable to a specific number of characters.

Use the pipe character "|" to insert formatting expressions.

Syntax:
{{<entry-variable>|<formatting-expression>(<value>)}}
Tip: You can chain formatting expressions with the pipe "|" character.

Example: The description Entry Variable chains two formatting expressions that modify the HTML and character limit of the value respectively.

{{description|strip_html|trim(14)}}

You can include any of the following formatting expressions:

  • dateformat

    Formats how the date is displayed. The default format is EEE, dd MM yyyy HH:mm:ss Z.

    Note: The dateformat expression supports the parse and format patterns of the SimpleDateFormat Java class.

    You can modify the default date format with your own specification.

    Example: The publication date is displayed in the format yyyy-MM-dd.

    {{pubDate|dateformat("yyyy-MM-dd")}}
  • extract_image

    Extracts only an image or image URL.

    Example: The image in the description is displayed with none of the description text.

    {{description|extract_image}}

    For entry values that contain multiple images, you can specify which image to extract.

    Example: Only the second image in the description is displayed with none of the description text.

    {{description|extract_image(2)}} 

    Include the true parameter to extract only the image URL.

    Example: This example extracts the URL for the first image in the description.

    {{description|extract_image(1, true)}}
  • strip_images

    Removes all img HTML tags.

  • strip_html

    Removes all HTML tags.

  • trim

    Truncates a text value to a character limit that you specify, and appends the value with an ellipsis.

    Example: All titles are limited to 50 characters.

    {{title|trim(50)}}

    Include the true parameter to end the truncated value with the last complete word appended with an ellipsis.

    Example: All descriptions are limited to 100 characters and end with the last complete word appended with an ellipsis.

    {{description|trim(100, true)}}

Feed Parser Template Example

The following example includes custom text, a feed variable, an entry loop with optional parameters, and entry variables with optional formatting expressions.

Articles from {{feed:title}}

{{entry_loop filter-variable="category" filter-value="Bronto" filter-type="matches"}}
    {{title}}
    {{description|trim(50, true)}}
    Read the full article by {{authorVariable}} at {{link}}.
    {{pubDate|dateformat("EEE dd-MM-yyyy")}}
    {{imageVariable|extract_image}}
{{/entry_loop}}