SXA 9.3.0 with Scriban

Custom objects, extensions galore and functions everywhere.

27/01/2020
Dominic Sinclair-Moore
FOUNDER
Dominic profile picture
MacBook Pro on top of brown table

Overview

With the introduction of Scriban in SXA 9.3.0, the flexibility given to front-end developers is better than ever. You may not be at the point to implement JavaScript Services for Sitecore (JSS) but with Scriban you're giving back some of the control. Out of the box, SXA provides us with embedded items (eg. i_home or i_item) and context objects (eg. o_model or o_context) as well as many additional functions and item/field extensions too. Sitecore has plenty of documentation on Scriban. That is all well and good, but why the change to Scriban in the first place? In short, the SXA development team needed an alternative to NVelocity to improve the feature set and flexibility within SXA . After a period of research and development, Scriban was chosen for it's uncompromising performance and flexibility in comparison to many other templating engines.

Performance metrics of the different template engines considered by the SXA development team

The out of the box Scriban extensions created by Sitecore will satisfy most developers needs with the ability to pipe through functions and query the full Sitecore tree without adding any additional code behind. If you find yourself in the situation that doesn't seem possible in Scriban or at least very complex, you may want to create an item extension to simplify the process and enable the functionality for all items, for example. You may also want to create a function with one purpose, for example fetching the URL within a link field.

If neither of these methods seem viable to you, most likely you are migrating from NVelocity than developing something new within Scriban. In this case I would still strongly recommend trying the previous two methods to simplify the code base and enabling front-end developers to be able to take more control of rendering the data which is very similar in JavaScript Services for Sitecore (JSS). I would recommend keeping the above quote in mind when "migrating" as you'll find Scriban is more powerful than you initially thought. If this is still not possible then check out our post on how to migrate NVelocity Extensions to Scriban.

Recent blog posts

At dotnet, we blend innovation, creativity, and technology to craft transformative digital solutions. From consultancy and engineering to data analytics, cloud hosting, and innovation, we offer a spectrum of services. Partner with us and embark on a journey of digital excellence.

What we do
  • Services
  • Work

© 2024 dotnet. All rights reserved.