Usage
dimension: field_name {
html: <img src="http://www.brettcase.com/ product_images/{{ value }}.jpg"/> ;;
}
}
Hierarchyhtml |
Possible Field TypesDimension, Dimension Group, MeasureAcceptsAn HTML expression, possibly using Liquid template elements, followed by two semicolons |
Definition
The html
parameter lets you specify the HTML that will be contained by a field.
You can also get access to the values that would typically be in the field by using Liquid variables. This lets you create a number of useful functions, including links to other related Looks, links to external websites, or images.
Using valid HTML
In order to prevent certain security exploits, Looker restricts which HTML tags and attributes may be used, as well as which CSS properties may be used. See our HTML sanitization documentation page for more details.
Liquid variables
The html
parameter supports Liquid variables. See the Liquid variables documentation page for information about how to make full use of these variables.
Examples
Here are some examples for using the html
field parameter.
HTML formatting only renders in table, table (legacy), and single value chart visualizations and in visualization tooltips when combining multiple fields. Any interactive content placed in a map chart’s tooltip with the
html
parameter will not be accessible on dashboards that use the new dashboard experience, although it will be accessible on Looks, Explores, and legacy dashboards.
Using Liquid variables in the html
parameter
This example shows how most of the Liquid variables would appear in an html
parameter. Consider a total_order_amount
definition:
The cell value displayed for total_order_amount
would look like this:
• value: 8521935
• rendered_value: 8,521,935.00
• linked_value: 8,521,935.00
• link: /explore/thelook/orders?fields=orders.order_amount&limit=500
• model: thelook
• view: orders
• explore: order_items
• field: total_order_amount
• dialect: mysql
• access filter: brettcase.com
• user attribute: northeast
• query timezone: America/Los_Angeles
• filters: NOT NULL
Conditionally format a count according to its values:
Exploring data with the html
parameter
HTML formatting only renders in table, table (legacy), and single value chart visualizations and in visualization tooltips when combining multiple fields. Any interactive content placed in a map chart’s tooltip with the
html
parameter will not be accessible on dashboards that use the new dashboard experience, although it will be accessible on Looks, Explores, and legacy dashboards.
Imagine you have a field in your data called status
, which gives the status of each order. The possible values for status
are:
Paid
Shipped
Returned
While exploring your data, you might want to have a separate background color for each status. This can be done using Liquid html in the html:
parameter of a dimension. This would look something like:
In your table, this will look like:
You can use the same syntax to add icons or images based on cell values:
In your table, this will look like:
Generating product images
Here is an example of how to add the picture of a product into Looker using an <img>
tag, based on the product’s ID:
Maintaining drill-down links
To maintain drill-down links when formatting output using the html
parameter, you can include the HTML tag <a href="#drillmenu" target="_self">
. For example: