zesty.io

Product

Use Cases

Integrations

Learn

Include Syntax

Learn more about how use Parsley's {{ include }} syntax which allows you insert a snippet within the view you are in.

{{ include }} allows you to insert snippets and endpoints within the view you are in.

Globally Available Views, Snippets, and Endpoints

#

When you create a snippet in the Web IDE, whether it be an HTML snippet, HTML Ajax, or JSON Ajax, these snippets are available globally. To insert this snippet, you'll need to use the {{ include }} Parsley call and the name of your snippet.

While the {{ include }} prompt is commonly used for snippets, users can also use the {{ include }} prompt for including view files within one another. For example, if you have a view with a Reference Name of contact_us the {{ include }} prompt would take the form of {{ include contact_us }}.

If the piece of code that's being included is an endpoint be sure to use the full name of the endpoint.

Common Usage

One common use of snippets is to create a globally available header and footer. In the example below we have two separate HTML snippets: one called header and the other called footer. We want these to load in every page of our instance therefore we add them to the Loader file. In the Loader file, we add calls for the header and footer snippet calls as follows:

Get a full walk-through for how to do this with the Using Snippets guide that's linked below.

Using Snippets

Working with Remote Files

{{ include }} can also pull in text from a remote file. The file must be accessible without authentication. There is a 3 second timeout for every request, if your remote file takes longer than 3 seconds to return, you will get a blank string. {{ include }} will grab the remote string and parse it with Parsley. You can use Parsley code in your remote text as well.

Using Dynamic Values in Includes

Includes make use dynamic reference to globals, settings, query parameters, path parts, post values, and this content values. The scope is limited to just those values because include are processes before parsley starts its rendering process.

Note: Includes are part of Parsley, but are processed before Parsley starts to render, therefore developers are limited to the scope of the values listed below.

  • Settings are accessed like {settings.general.site_protocol}
  • Content item values are accessed like {this.my_title}
  • Globals are accessed like {globals.site_name}
  • Query Params are accessed like {query_param.key} or {get_var.key}
  • Path Parts accessed like {path_part.0} e.g. /first/part/ {path_part.0} returns 'first'
  • Multiple like this "my page is {this.title} from {globals.site_name}"

Start Here

We will listen to your needs and walk you through how Zesty can help your team.

Connect with Content Experts

Book a free 15-minute consultation with a content expert. Discuss your application, pain points and requirements. Understand how Zesty's lower total cost of ownership, features, functionality can elevate your business by creating extraordinary digital experiences.

Trusted By

zesty customer logo Sonyzesty customer logo Rocket Leaguezesty customer logo Singlifezesty customer logo Acornszesty customer logo Phoenix Sunszesty customer logo Wattpadzesty customer logo Corner Shopzesty customer logo Bjs

Enter your details to connect with a Content Expert

First Name

Last Name

Email

Phone (optional)

Company

Please tell us about your project (optional)

G2 MOMENTUM LEADER

zesty customer logo zesty customer logo zesty customer logo zesty customer logo