ISML Template Best Practices

ISML Template Best Practices

ISML Template Best Practices

  • Jonatan Jumbert

  • 2 minute read

Rendering Templates

When Salesforce Commerce Cloud generates web pages on the application server, it uses ISML Templates and scripts within the Controllers. B2C Commerce Script API in the Controllers access the database layer if necessary. We are going to describe the best practices for:

image
  • ISML Templates

  • Scripting in Templates

  • Local Includes

  • Remote Includes

  • Efficient Template Coding

SFCC Secrets You Need!

Imagine what you’re missing in our other guides! Stay ahead of the competition, get exclusive pro tips, and master Salesforce Commerce Cloud like never before.

👉 Subscribe NOW and never struggle with SFCC again!

ISML Templates

You should keep ISML as clean as possible. It’s always good for performance tuning and maintainability of your site.

Scripting in ISML Templates

You can write Salesforce Commerce Cloud scripts inside ISML templates using <isscript> tag. In general though, you should use scripts in your controllers and pass the information via viewData rather than using <isscript> blocks.

To ensure that you can diagnose performance issues, break large <isscript> blocks into multiple pieces. Smaller scripts help with readability and pinpointing bottlenecks efficiently.

Local Includes

Local includes are useful when you want to reuse partial templates. They are merged with the including template as an ISML file before it is compiled.

Pipeline dictionary variables (pdict) can be used in the included templates as well, without needing to initialize and fetch data again if the variables are already available.

Example:
<isinclude template="/components/your-template.isml" />

Remote Includes

For each remote include in a page, a placeholder is inserted and a page is delivered from the application server to the web server. The web server parses the page and calls for every include placeholder, which can cause "Ping-Pong" between the two servers.

Best practices for remote includes:

  • Do not use more than 20 remote includes within a page.

  • Avoid exceeding three levels of remote includes.

  • Reuse pipeline dictionary variables instead of recalculating data in separate includes.

Example:
<isinclude url="${URLUtils.https('Home-Show')}" />

Best Practices for Efficient Template Coding

  • Controllers should capture most of the business logic, while templates should only render the information aggregated in the controllers.

  • Use pagination to display large search result sets.

  • Remove unused SFRA/SiteGenesis ISML templates to avoid unnecessary resource consumption.

  • Use <isdecorate> to apply a page layout wrapper around content blocks.

  • Use <ismodule> when you have code snippets reused in multiple templates.


Recommended Courses