AI answers drawn only from these docs, with links to the pages used.

Liquid Tags: Insites

Last updated on October 15, 2026

background

Invokes code within the tag asynchronously, in the background. You will only have access to variables you explicitly pass to the background tag. The context object is available by default, but with limitations - you need to explicitly pass page/layout metadata if you want to use it, as well as device and constants.

Params

NameTypeDescription
optionsHashAny variable provided to the background tag will become accessible in the code.
options.delayFloatWhich defines the number of minutes to delay running code (defaults to 0, which means run code as soon as possible).
options.priorityStringlow, default or high. See the AsyncCallbackPriority enum.
options.max_attemptsIntegerThe number of times to re-try a job upon failing. Default is 1, maximum is 5.
options.source_nameStringYour label of the job to help you identify it.

Examples

cache

Checks if there's a string cached for the given key. If yes, it just returns the value without processing anything inside the cache tag, otherwise, it executes code, and stores the result in the cache. When you hit the page with such code for the first time, the code will be executed and hence it will iterate through the loop and generate random strings. However, then the result of the block will be cached and all the following requests within 20 seconds would not invoke the code - instead, it would just take the value from the cache. The output will not change. When the cache expires, the code will be evaluated again, producing another set of random strings. The cache is automatically invalidated if any changes are applied to any view/translation.

Params

NameTypeDescription
keyStringThe key which should uniquely identify the cached fragment.
expireIntegerOptional. The number of seconds since populating the cache to expiration.

Examples

content_for

Stores a block of markup in an identifier for later use. Render it later with yield tag.

Params

NameTypeDescription
nameStringThe markups will be stored under this name.
flushBooleanOptional. If the flush parameter is true content_for replaces the blocks it is given instead of appending content to the existing one.

Examples

context

Set locale in context to a given language.

Params

NameTypeDescription
languageStringLanguage 2 letter.

Examples

export

Makes variables defined inside partial accessible anywhere via context.exports.`namespace`

Params

NameTypeDescription
variableAnyVariable to be stored inside the namespace.
namespaceStringNamespace under which variable will be in context.exports.

Examples

form

Generates an HTML form element for a resource. Use it inside a form file in the app/forms directory. Inside the tag you can use the `form_builder` variable.

Params

NameTypeDescription
html-idStringSets the id attribute on the <form> element.
html-novalidateStringAdds the novalidate attribute to the <form> element.
html-classStringAdds a CSS class to the <form> element.
html-multipartBooleanAdds enctype='multipart/form-data' to the <form> element. Multipart is enabled by default.
html-data-attr[String] Adds a data attribute to the <form> element, for example html-data-user-id adds data-user-id.

Examples

function

Allows to store a variable returned by a partial. Partial needs to return data with `return` tag. All variables needs to be passed explicitly to function. Variables from upper scope are not visible in function. *Note:* `context` is not available inside the function partial unless explicitly passed as a variable.

Examples

graphql

Executes a GraphQL query stored in a file, or a GraphQL query written inline. All arguments provided to the tag will be passed to GraphQL. It returns a hash with the data or the errors that occurred (for example, variable type mismatch, required variable not provided, syntax error) etc.

Params

NameTypeDescription
query_nameStringName of the GraphQL query. For get_users.graphql file name of the query is get_users
argumentsHashOptional. key:value pair(s) which will be passed to GraphQL query. For example, if your query looks like `query my_query($email: String!)`, then you can provide `email: "my-email@example.com"`
argsHash|JSONOptional. Either a Hash or a String of the arguments which will be passed to GraphQL query. See examples below.

Examples

hash_assign

Deprecated. Use assign instead. assign writes into a hash with dot or bracket notation, for example . Code that uses hash_assign works, but use assign in new code.

Examples

include_form

This tag should be used to render forms defined in forms directory.

Params

NameTypeDescription
form_nameStringName of the form in the forms directory.
idIDID of the resource you want to edit.
parent_resource_idStringName of the resource type, i.e. name of custom_model_type, transactable_type, user_profile_type.

Examples

log

Prints information to the instance logs. To view logs, run in your project folder and open http://localhost:3030/logs. To see logs in the terminal, run .

Params

NameTypeDescription
messageAnyAny object that can be printed.
typeStringType of log entry. Use it to tag your logs to make it easier to differentiate logs. If you set it to 'error' insites-cli will also notify your OS about it if your OS supports it.
envStringEnvironment where the entry should be created; can be any of 'all', 'staging', 'production'. Default: 'all'

Examples

parse_json

Parses a JSON string into a hash or array. For JSON you write in the template, use an assign literal instead: . Keep parse_json for a JSON string that arrives at runtime, such as an API response.

Params

NameTypeDefinition
variable_nameStringThe variable name that will be used to assign contents after it is parsed.
contentStringValid JSON string to be assigned.

Examples

print

Print variable, skipping any additional sanitization. It provides a way to display a variable which consists of both safe and unsafe html. Warning: Do not use it with data entered by users as it is gonna cause XSS.

Params

NameTypeDescription
variableStringA variable containing safe and potentially unsafe HTML.

Examples

redirect_to

Redirects browser to target

Params

NameTypeDescription
targetString
Path or url.
statusInt3xx HTTP code, default 302.

Examples

response_headers

Allows you to set additional HTTP headers for the response.

Params

NameTypeDescription
headersStringHeaders as JSON string, default {}.

Examples

response_status

Allows you to set HTTP status for the response. Default 200.

Params

NameTypeDescription
statusIntHTTP status, default 200

Examples

return

Used inside a partial invoked by a function tag to return a variable.

Examples

session

Stores data during user's session Sets field of given name to given value in context.session.

Examples

sign_in

Sign in user.

Params

NameTypeDefinition
user_idStringuser id

Examples

spam_protection

Generates HTML for spam protection. Supports three strategies: recaptcha_v2 and recaptcha_v3 (Google reCAPTCHA) and hcaptcha (hCaptcha).

Params

NameTypeDescription
strategyStringName of protection strategy. Default is recaptcha_v2.
actionStringAction name for reCAPTCHA V3, action may only contain alphanumeric characters and slashes

Examples

theme_render_rc

Lets you set search paths for theme partials with the theme_search_paths property in app/config.yml. For example:

Examples

transaction

Runs all database writes inside the block as one transaction. If one fails, all are rolled back. The timeout parameter (in seconds) aborts and rolls back a block that runs too long. Variables inside and outside the block are shared. A background job scheduled inside the block is queued only after the transaction commits.

Params

NameTypeDescription
timeoutIntegerOptional. Number of seconds before the block is aborted and rolled back.

Examples

rollback

Rolls back the current transaction by hand. Use it inside a transaction block.

Examples

try

Catches errors. This is most useful with in app/config.yml. try_rc is another spelling of the same tag.

Examples

yield

Execute code wrapped inside content_for

Params

NameTypeDescription
nameStringName of content_for block.

Examples

Have a suggestion for this page?

Didn't quite find what you are looking for or have feedback on how we can make the content better then we would love to hear from you. Please provide us feedback and we will get back to you shortly.