HubL Reference

Table of contents
Close

HubL supported filters

Filters affect the ultimate output of your HubL. They can be applied to various HubL statements and expressions to alter the template markup outputted by the server.

The basic syntax of a filter is |filtername. The filter is added directly following the statement or the expression, within its delimeters. Some filters have additional parmeters that can be added in parentheses. The basic syntax of a filter with a string, a number, and a boolean parameters is: |filtername('stringParameter', 10, true).  Notice that string parameters shoud be written in quotes. Also note that HubL filters have an alias that can be used to serve the same purpose as the primary filter.

The following article contains all of the supported HubL filters.

Please note that using filters on personalization variables (contact and company variables) is not currently supported for email in HubSpot. Filters can be applied to these properties on COS page and blog templates.

abs

Gets the absolute value of a number. You can use this filter to ensure that a number is positive.

{% set my_number = -53 %} 


{{ my_number|abs }}
53

add

Adds a numeric value to another numeric value. This filter functions the same as the + operator. The parameter in paretheses is the addend that you are combining with your initial numeric value.

{% set my_num = 40 %} 


{{ my_num|add(13) }}
53

attr

Renders the attribute of a dictionary. This filter is the equivalent of printing a variable that exists within a dictionary, such as content.absolute_url. The parameter specifies which attribute to print.

parameters: attr('attribute_name')

{{ content|attr('absolute_url') }} 

http://designers.hubspot.com/docs/hubl/hubl-filters

batch

A batch filter groups up items within a sequence. It accepts two parameters. The first parameter specifies the number of items to include in the batch and the second parameter specifies what to include used to fill up any missing items.

In the example below, there is variable containing a sequence of types of fruits. The batch filter is applied to a loop that iterates through the sequence. The nested loop runs three times to print 3 types of fruit per row, before the outer loop runs again. Notice in the final output that since there are only 5 types of fruit, the final item is replaced by a &nbsp (the second parameter).

parameters: batch(linecount, fill_with=None)


{% set rows = ['apples', 'oranges', 'pears', 'grapes', 'blueberries'] %}

<table>
{% for row in rows|batch(3, '&nbsp;') %}
   <tr>
    {% for column in row %}
        <td>{{ column }}</td>
    {% endfor %}
    </tr> 
{% endfor %}
</table>


<table>
<tbody>
    <tr>
        <td>apples</td>
        <td>oranges</td>
        <td>pears</td>
   </tr> 
   <tr>
        <td>grapes</td>
        <td>blueberries</td>
        <td>&nbsp;</td>
    </tr> 
</tbody>
</table>

capitalize

Capitalize the first letter of a variable value. The first character will be uppercase, all others letters will retain their original case.

{% set sentence = "the first letter of a sentence should always be capitalized." %} 


{{ sentence|capitalize }}
The first letter of a sentence should always be capitalized.

center

The center filter uses whitespace to center text within a given field length. This filter is not recommended or particularly useful since HubSpot's HTML compiler will automatically strip out the white space; however, it is included here for the sake of comprehensiveness. The paramter specifies the length of whitespace to center the text in.The example below shows a center filter being applied to a variable in a pre tag, so the whitespace isnt stripped out.

parameters: center(width=40)


<pre>
{% set var = "string to center" %}
{{ var|center(80) }}
</pre>

convert_rgb

Converts a HEX value to an RGB string. This is useful if you need to convert color variables to RGB to be used with a RGBA CSS declaration. In the example below, the value set by a color module is converted to an RGB value and used in an RGBA CSS declaration.


{% set my_color = "#FFFFFF" %}
{{ my_color|convert_rgb }}

{% color "my_color" color="#000000", export_to_template_context=True %}
<div style="background: rgba({{ widget_data.my_color.color|convert_rgb }}, .5)"></div>


255, 255, 255

<div style="background: rgba(0, 0, 0, .5)"></div>

cut

Removes a string from a value. This filter can be used to match and cut out a specific part of a string. The parameter specifes the part of the string that should be removed. The example below removes the space and the word world from the original variable value.

parameters: cut('characters to cut')

{% set my_string = "Hello world." %} 


{{ my_string|cut(' world') }}
Hello.

datetimeformat

Formats a date object. By default, HubSpot date variables print as timestamps. The datetimeformat filter is used to convert that timestamp into a legible date and/or time. The filter's parameters, listed in the table below, dictate how the time variable ultimately renders. 

Alias: date

{{ content.updated|datetimeformat('%B %e, %Y') }} 


{{ content.updated|datetimeformat('%a %A %w %d %e %b %B %m %y %Y %H %I %k %l %p %M %S %f %z %Z %j %U %W %c %x %X %%') }}

May 11, 2015

Mon Monday 15 11 11 May May 05 15 2015 14 02 14 02 PM 47 41 0000 +0000 +0000 131 20 20 Mon May 11 14:47:41 2015 05/11/15 14:47:41 %

 
Directive Meaning Example
%a Weekday as locale’s abbreviated name.
Sun, Mon, ..., Sat (en_US);
So, Mo, ..., Sa (de_DE)
%A Weekday as locale’s full name.
Sunday, Monday, ..., Saturday (en_US);
Sonntag, Montag, ..., Samstag (de_DE)
%w

Weekday as a decimal number, where 1 is Sunday and 7 is Saturday.

NOTE: This differs from python day numbers which start at 0.

1, 2, ..., 7
%d Day of the month as a zero-padded decimal number. 01, 02, ..., 31
%e Day of the month as a decimal number, without padding. 1, 2, ..., 31
%b Month as locale’s abbreviated name.
Jan, Feb, ..., Dec (en_US);
Jan, Feb, ..., Dez (de_DE)
%B Month as locale’s full name.
January, February, ..., December (en_US);
Januar, Februar, ..., Dezember (de_DE)
%m Month as a zero-padded decimal number. 01, 02, ..., 12
%y Year without century as a zero-padded decimal number. 00, 01, ..., 99
%Y Year with century as a decimal number. 1970, 1988, 2001, 2013
%H Hour (24-hour clock) as a zero-padded decimal number. 00, 01, ..., 23
%I Hour (12-hour clock) as a zero-padded decimal number. 01, 02, ..., 12
%k The hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. 1,  2, ..., 12
%l (note this is a lower case L) The hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. 1,  2, ..., 12
%p Locale’s equivalent of either AM or PM.
AM, PM (en_US);
am, pm (de_DE)
%M Minute as a zero-padded decimal number. 00, 01, ..., 59
%S Second as a zero-padded decimal number. 00, 01, ..., 59
%f Microsecond as a decimal number, zero-padded on the left. 000000, 000001, ..., 999999
%z UTC offset in the form +HHMM or -HHMM (empty string if the the object is naive). (empty), +0000, -0400, +1030
%Z Time zone name (empty string if the object is naive). (empty), UTC, EST, CST
%j Day of the year as a zero-padded decimal number. 001, 002, ..., 366
%U Week number of the year (Sunday as the first day of the week) as a zero padded decimal number. All days in a new year preceding the first Sunday are considered to be in week 0. 00, 01, ..., 53
%W Week number of the year (Monday as the first day of the week) as a decimal number. All days in a new year preceding the first Monday are considered to be in week 0. 00, 01, ..., 53
%c Locale’s appropriate date and time representation.
Tue Aug 16 21:30:00 1988 (en_US);
Di 16 Aug 21:30:00 1988 (de_DE)
%x Locale’s appropriate date representation.
08/16/88 (None);
08/16/1988 (en_US);
16.08.1988 (de_DE)
%X Locale’s appropriate time representation.
21:30:00 (en_US);
21:30:00 (de_DE)
%% A literal '%' character. %

default

If the value is undefined it will return the first parameter, otherwise the value of the variable will be printed. If you want to use default with variables that evaluate to false, you have to set the second parameter to true. The first example below would print the message if the variable is not defined. The second example applied the filter to an empty string, which is not undefined, but it prints a message due to the second parameter.

The default filter has the following alias: d

parameters: default(default_value='variable is undefined', boolean)

{% my_variable|default('my_variable is not defined') %}


{% ''|default('the string was empty', true) %}
my_variable is not defined
the string was empty

dictsort

Sort a dict and yield (key, value) pairs. Dictionaries are unsorted by default, but you can print a dictionary, sorted by key or value. The first parameter is a boolean to determine, whether or not the sorting is case sensitive. The second parameter determines whether to sort the dict by key or value. The example below prints a sorted contact dictionary, with all the know details about the contact.

parameters:dictsort(case_sensitive=False, by='value')


{% for item in contact|dictsort(false, 'value') %}
    {{item}}
{% endfor %}


A sorted contact dictionary

divide

Divide the current value by a divisor. The parameter passed is the divisor. This filter is an alternative to the / operator.

parameters: divide(divisor=2)

{% set numerator = 106 %}


{% numerator|divide(2) %}
53

divisible

An alternative to the divisibleby expression test, the filter divisble will evaluate to true if the value is divisible by the given number.

parameters: divisible(divisor=2)


{% set num = 10 %}
{% if num|divisible(2) %}
The number is divisble by 2
{% endif %}


The number is divisble by 2

escape

Convert the characters &, <, >, ‘, and ” in string to HTML-safe sequences. Use this if you need to display text that might contain such characters in HTML. Marks return value as markup string.

Alias: e

{% set escape_string = "<div>This markup is printed as text</div>" %} 


{{ escape_string|escape }}
<div>This markup is printed as text</div>

filesizeformat

Format the value like a ‘human-readable’ file size (i.e. 13 kB, 4.1 MB, 102 Bytes, etc). Per default decimal prefixes are used (Mega, Giga, etc.), if the parameter is set to True the binary prefixes are used (Mebi, Gibi).

parameters: filesizeformat(boolean)

{% set bytes = 100000 %} 


{{ bytes|filesizeformat }}
100.0 KB

first

Returns the first item in a sequence.

{% set my_sequence = ['Item 1', 'Item 2', 'Item 3'] %} 


{{ my_sequence|first }}
Item 1

float

Convert the value into a floating point number. If the conversion doesn’t work it will return 0.0. You can override this default using the first parameter.

parameters: float(0.1)

{% text "my_text" value='25', export_to_template_context=True %} 


{{ widget_data.my_text.value|float + 28 }}
53.0

forceescape

Strictly enforce HTML escaping. In HubSpot's environment there isn't really a use case for double escaping, so this is generally behaves the same as the escape filter. 

{% set escape_string = "<div>This markup is printed as text</div>" %} 


{{ escape_string|forceescape }}
<div>This markup is printed as text</div>

format

Apply Python string formatting to an object. %s can be replaced with another variable.

{{ "Hi %s %s"|format(contact.firstname, contact.lastname) }} 

Hi Brian Halligan

groupby

The groupby filter groups a sequence of objects by a common attribute.The parameter sets the common attribute to group by.

parameters: groupby(attribute='name_of_attribute')


<ul>
{% for group in contents|groupby('blog_post_author') %}
    <li>{{ group.grouper }}<ul>
    {% for content in group.list %}
        <li>{{ content.name }}</li>
    {% endfor %}</ul></li>
{% endfor %}
</ul>


<ul>
    <li>Blog author 1
        <ul>
        <li>Post by Blog author 1<li>
        <li>Post by Blog author 1<li>
        <li>Post by Blog author 1<li>
        </ul>
    </li>  
    <li>Blog author 2
        <ul>
        <li>Post by Blog author 2<li>
        <li>Post by Blog author 2<li>
        <li>Post by Blog author 2<li>
        </ul>
    </li>
    <li>Blog author 3
        <ul>
        <li>Post by Blog author 3<li>
        <li>Post by Blog author 3<li>
        <li>Post by Blog author 3<li>
        </ul>
    </li>
</ul>

indent

The indent filter uses whitespace to indent text within a given field length. This filter is not recommended or particularly useful since HubSpot's HTML compiler will automatically strip out the white space; however, it is included here for the sake of comprehensiveness. The example below shows a center filter being applied to a variable in a pre tag, so the whitespace isnt stripped out. The first parameter controls the amount of whitespace and the second boolean toggles whether to indent the first line.

parameters: indent(width=4, indentfirst=False)


<pre>
{% set var = "string to indent" %}
{{ var|indent(2, true) }}
</pre>

int

Convert the value into an integer. If the conversion doesn’t work it will return 0. You can override this default using the first parameter.

parameters: int(0)

{% text "my_text" value='25', export_to_template_context=True %} 


{{ widget_data.my_text.value|int + 28 }}
53

join

Return a string which is the concatenation of the strings in the sequence. The separator between elements is an empty string per default, you can define it with the optional parameter. The second parameter can be used to specify an attribute to join.

join(d='', attribute='name')


{% set my_list = [1, 2, 3] %}
{{ my_list|join }}
{{ my_list|join('|') }}


123
1|2|3

last

Returns the last item of a sequence.

{% set my_sequence = ['Item 1', 'Item 2', 'Item 3'] %}


{% my_sequence|last %}
Item 3

length

Return the number of items of a sequence or mapping.

Alias: count

{% set services = ['Web design', 'SEO', 'Inbound Marketing', 'PPC'] %} 


{{ services|length }}
4

list

Convert the number values into a list. If it was a string the returned list will be a list of characters. To add strings to a sequence, simply add them to the string variables to the sequence delimiters [ ].


{% set one = 1 %}
{% set two = 2 %}
{% set three = 3 %}
{% set list_num = one|list + two|list + three|list %}
{{ list_num }}


[1,2,3]

lower

Convert a value to all lowercase letters.

parameters: int(0)

{{ text "text" value='Text to MAKE Lowercase', export_to_template_context=True }} 


{{ widget_data.text.value|lower }}
text to make lowercase

map

Applies a filter on a sequence of objects or looks up an attribute. This is useful when dealing with lists of objects but you are really only interested in a certain value of it.

The basic usage is mapping on an attribute. For example, if you want to use conditional logic to check if a value is present in a particular attibute of a dict. Alternatively, you can let it invoke a filter by passing the name of the filter and the arguments afterwards.

parameters:map('attribute) or map('filter_to_apply')

{% set seq = ['item1', 'item2', 'item3'] %} 


{{ seq|map('upper') }}
[ITEM1, ITEM2, ITEM3]

md5

Calculates the md5 hash of the given object

{{ content.absolute_url|md5 }} 

923adb4ce05a4c6342c04c80be88d15e

multiply

Multiplies a value with a number. Functions the same as the * operator.
{% set n = 20 %} 


{{ n|multiply(3) }}
60

pprint

Pretty print a variable. This prints the type of variable and other info that is useful for debugging.

{% set this_var ="Variable that I want to debug" %} 


{{ this_var|pprint }}
{% raw %}(String: Variable that I want to debug){% endraw %}

random

Return a random item from the sequence.


{% for content in contents|random %}
<div class="post-item">Post item markup</div>
{% endfor %}


<div class="post-item">Random post</div>

reject

Filters a sequence of objects by applying an expression test to the object and rejecting the ones with the test succeeding.

parameters: reject(exp_test='truthy')

{% set some_numbers = [10, 12, 13, 3, 5, 17, 22] %}


{% some_numbers|reject('even') %}
[13, 3, 5, 17]

rejectattr

Filters a sequence of objects by applying a test to an attribute of an object or the attribute and rejecting the ones with the test succeeding.

parameters: rejectattr(attr='attribute_name', exp_test='truthy')


{% for content in contents|rejectattr('post_list_summary_featured_image') %}
<div class="post-item">
{% if content.post_list_summary_featured_image %}
    <div class="hs-featured-image-wrapper">
            <a href="{{content.absolute_url}}" title="" class="hs-featured-image-link">
            <img src="{{ content.post_list_summary_featured_image }}" class="hs-featured-image">
            </a>
    </div>
{% endif %}
{{ content.post_list_content|safe }}
</div>
{% endfor %}


<div class="post-item">Post with no featured image</div>
<div class="post-item">Post with no featured image</div>
<div class="post-item">Post with no featured image</div>

replace

Replace all instances of a substring with a new one. The first argument is the substring that should be replaced, the second is the replacement string. If the optional third argument count is given, only the firstcount occurrences are replaced.

parameters: replace(old, new, count=None)


{% if topic %}<h3>Posts about {{ page_meta.html_title|replace('Blog | ', '') }}</h3>{% endif %}


<>Posts about topic name</h3>

reverse

Reverse the object or return an iterator the iterates over it the other way round.


{% set nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] %}
{% for num in nums|reverse %}
{{ num }}
{% endfor %}


10 9 8 7 6 5 4 3 2 1

round

Round the number to a given precision. The first parameter specifies the precision (default is 0), the second the rounding method:

  • 'common' rounds either up or down
  • 'ceil' always rounds up
  • 'floor' always rounds down

If you don’t specify a method 'common' is used.

parameters: round(precision, 'rounding_method')

{{ 52.5|round }} 


{{ 52.5|round(0, 'floor') }}

53

52

safe

Mark the value as safe which means that in an environment with automatic escaping enabled this variable will not be escaped.

{{ content.post_list_content|safe }} 

<p>HTML post content that is not escaped. </p>

select

Filters a sequence of objects by applying a test to the object and only selecting the ones with the test succeeding.

parameters: select(exp_test='truthy')

{% set some_numbers = [10, 12, 13, 3, 5, 17, 22] %} 


{{ some_numbers|select('even') }}
[10, 12, 22] 

selectattr

Filters a sequence of objects by applying a test to an attribute of an object and only selecting the ones with the test succeeding. The first parameter specifies the attribute to select, and the second specifies a specifc value to filter for. In the example below a blog post loop is filtered to only return posts with featured images.

parameters: selectattr(attr='attribute_name', exp_test='truthy')

 


{% for content in contents|selectattr('post_list_summary_featured_image') %}
<div class="post-item">
{% if content.post_list_summary_featured_image %}
    <div class="hs-featured-image-wrapper">
            <a href="{{content.absolute_url}}" title="" class="hs-featured-image-link">
            <img src="{{ content.post_list_summary_featured_image }}" class="hs-featured-image">
            </a>
    </div>
{% endif %}
{{ content.post_list_content|safe }}
</div>
{% endfor %}


<div class="post-item">
<div class="hs-featured-image-wrapper">
            <a href="http://blog.hubspot.com/marketing/how-to-get-a-job" title="" class="hs-featured-image-link">
            <img src="//cdn2.hubspot.net/hub/53/hubfs/00-Blog-Related_Images/landing-a-job-featured-image.png?t=1431452322770&width=761" class="hs-featured-image">
            </a>
    </div>
Post with featured image
</div>

shuffle

Randomizes the order of iteration through a sequence. The example below shuffles a standard blog loop.


{% for content in contents|shuffle %}
<div class="post-item">Markup of each post</div>
{% endfor %}


<div class="post-item">Markup of each post 5</div>
<div class="post-item">Markup of each post 3</div>
<div class="post-item">Markup of each post 1</div>
<div class="post-item">Markup of each post 2</div>
<div class="post-item">Markup of each post 4</div>

slice

Slice an iterator and return a list of lists containing those items. The first parameter specifies how many items will be sliced, and the second parameter specifies characters to fill in empty slices.

parameters: slice(slices, 'filler')


{% set items = ['laptops', 'tablets', 'smartphones', 'smart watches', 'TVs'] %}
<div class="columwrapper">
  {% for column in items|slice(3,' ') %}
    <ul class="column-{{ loop.index }}">
    {% for item in column %}
      <li>{{ item }}</li>
    {% endfor %}
    </ul>
  {% endfor %}
</div>


<div class="columwrapper">
    <ul class="column-1">
      <li>laptops</li>
      <li>tablets</li>
      <li>smartphones</li>
    </ul>
  
    <ul class="column-2">
      <li>smart watches</li>  
      <li>TVs</li>
      <li>&nbsp;</li>
    </ul>
</div>

sort

Sorts an iterable. This filter requires all parameters to sort by an attribute in HubSpot. The first parameter is a boolean to reverse the sort order. The second parameter determines whether or not the sorting is case sensitive. And the final parameter specifies an attribute to sort by. In the example below, posts from a blog are rendered and alphabetized by name.

parameters: reverse=False, case_sensitive=False, attribute='name')


{% set my_posts = blog_recent_posts('default', limit=5) %}

{% for item in my_posts|sort(False, False, 'name') %}
{{ item.name }}<br>


{% endfor %}


A post<br>
B post<br>
C post<br>
D post<br>
E post<br>

split

Splits the input string into a list on the given separator. The first parameter specifies the separator to split the variable by. The second parameter determines how many times the variable should be split. Any remaining items would remained group. In the example below, a string of names is split at the ";" for the first 4 names.

parameters: split('character_to_split_by', number_of_splits)


{% set string_to_split = "Stephen; David; Cait; Nancy; Mike; Joe; Niall; Tim; Amanda" %}
{% set names = string_to_split|split(';', 4) %}
<ul>
{% for name in names %}
<li>{{ name }}</li>
{% endfor %}
</ul>


<ul>
<li>Stephen</li>
<li>David</li>
<li>Cait</li>
<li>Nancy; Mike; Joe; Niall; Tim; Amanda</li>
</ul>

string

Converts a different variable type to a string. In the example below, a integer is converted into a string (pprint is used to confirm the change in variable type).

{% set number_to_string = 45 %} 


{{ number_to_string|string|pprint }}
{% raw %}(String: 45){% endraw %} 

striptags

Strip SGML/XML tags and replace adjacent whitespace by one space. This filter can be used to remove any HTML tags from a variable.

{% set some_html = "<div><strong>Some text</strong></div>" %} 


{{ some_html|striptags }}
  some text  

sum

Adds numeric values in a sequence. The first parameter can specify an optional attribute and the second parameter sets a value to return if there is nothing in the variable to sum.

parameters: sum('attribute', nothing_to_sum)

{% set sum_this = [1, 2, 3, 4, 5] %} 


{{ sum_this|sum }}
15

title

Return a titlecased version of the value. I.e. words will start with uppercase letters, all remaining characters are lowercase.

{% text "my_title" label='Enter a title', value='My title should be titlecase', export_to_template_context=True %} 


{{ widget_data.my_title.value|title }}
My Title Should Be Titlecase

trim

Strips leading and trailing whitespace. HubSpot already trims whitespace from markup, but this filter is documented for the sake of comprehensiveness. 

{{ " remove whitespace " }} 


{{ " remove whitespace "|trim }}

 remove whitespace 

remove whitespace

truncate

Cuts of text after a certain number of characters. The default is 255. Please note that HTML characters are included in this count. The length is specified with the first parameter which defaults to 255. If the second parameter is true the filter will cut the text at length. Otherwise it will discard the last word. If the text was in fact truncated it will append an ellipsis sign ("..."). If you want a different ellipsis sign than "..." you can specify it using the third parameter.

parameters: truncate(number_of_character, breakword=False, end='...')

{{ "I only want to show the first sentence. Not the second."|truncate(40) }} 


{{ "I only want to show the first sentence. Not the second."|truncate(35, True, '..........') }}

I only want to show the first sentence.

I only want to show the first sente.......... 

truncatehtml

Truncates a given string, respecting html markup (i.e. will properly close all nested tags). This will prevent a tag from being remaining open after truncation. HTML characters do not count towards the character total. This filter has a length parameter and a truncation symbol parameter. There is a third boolean parameter that specifies whether words will be broken at length. This parameter is false by default in order to preserve the length of words.

parameter: truncatehtml(200, '...', false)

{% set html_text = "<p>I want to truncate this text without breaking my HTML<p>" %} 


{{ html_text|truncatehtml(28, '..' , false) }}
<p>I want to truncate this..</p>

unique

This filter extracts a unique set from a sequence or dict of objects. When filtering a dict, such as a list of posts returned by a function, you can specify the which attribute should be used to deduplicate items in the dict.

parameter: |unique(attr='name_of_attribute')

{% set my_sequence = ['one', 'one', 'two', 'three' ] %} 


{{ my_sequence|unique }}
[one, two, three]

unixtimestamp

This filter converts a datetime object into a unix timestamp.

{{ local_dt }} 


{{ local_dt|unixtimestamp }}

2017-01-30 17:11:44

1485814304000

upper

Convert a value to all uppercase letters.

{% text "text" value='text to make uppercase', export_to_template_context=True %} 


{{ widget_data.text.value|upper }}
TEXT TO MAKE UPPERCASE

urlencode

Escapes an url encodes a string using UTF-8 formatting.

{% text "encode" value="Escape & URL encode this string", label="Enter slug", export_to_template_context=True %} 


{{ widget_data.encode.value|urlencode }}
Escape+%26+URL+encode+this+string 

urlize

Converts URLs in plain text into clickable links. If you pass the filter an additional integer it will shorten the urls to that number. The second parameter is a boolean that dictates whether the link is rel="no follow". The final parameter lets you specify whether the link will open in a new tab.

parameters: urlize((40,no_follow=true, target='_blank')

{{ "http://hubspot.com/"|urlize }} 


{{ "http://hubspot.com/"|urlize(10, true, target='_blank') }}

<a href="http://hubspot.com/">http://hubspot.com/</a>

<a href="http://hubspot.com/" rel="nofollow" target="_blank">http://...</a>

wordcount

Count the number of words in a string.

{%  set count_words = "Count the number of words in this variable"  %} 


{{ count_words|wordcount }}
8

wordwrap

Causes words to wrap at a given character count. This works best in a <pre> because HubSpot strips whitespace by default.

parameter: wordwrap(character_count)

{% set wrap_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam efficitur, ipsum non sagittis euismod, ex risus rhoncus lectus, vel maximus leo enim sit amet dui. Ut laoreet ultricies quam at fermentum." %}


{% wrap_text|wordwrap(10) %}

Lorem

ipsum

dolor sit

amet,

consectetu
r

adipiscing

elit.

Etiam

efficitur,

ipsum non

sagittis

euismod,

ex risus

rhoncus

lectus,

vel

maximus

leo enim

sit amet

dui. Ut

laoreet

ultricies

quam at

fermentum.

xmlattr

Create an HTML/XML attribute string, based on the items in a dict. All values that are neither none 
nor undefined are automatically escaped. It automatically prepends a space in front of the item if the filter returned something unless the first parameter is false.

parameter: xmlattr(autospace=True)


{% set html_attributes = {'class': 'bold', 'id': 'sidebar'} %}
<div {{ html_attributes|xmlattr }}></div>


<div class="bold" id="sidebar"></div>