Questions tagged [scriban]

For questions related to the SXA Scriban templates.

Filter by
Sorted by
Tagged with
1 vote
1 answer
46 views

Error when adding scriban template to rendering variant migrated from 9.1.1 to 10.2

I'm currently in the process of upgrading our solution from Sitecore 9.1.1 to 10.2. Our solution has a number of nVelocity templates that I need to replace with scriban templates. I've also already ...
user avatar
  • 13
2 votes
1 answer
63 views

How to increment value and use it in sc_placeholder

Is it possible in Scriban to use the value from the variable, and then increment it and then use that value inside the sc_placeholder If it is not possible using the basic default Scriban, maybe ...
user avatar
  • 329
0 votes
2 answers
77 views

How to have dynamic placeholders within the for loop?

I am trying to make the dynamic placeholders with different numbers in the for loop. Now when I make the placeholder I only get the same name and number at the end (test-1-1). How to make it so that ...
user avatar
  • 329
0 votes
0 answers
23 views

How to check the length of selected items in for loop using Scriban? [duplicate]

Is there a way to check how many items are selected from Treelist using Scriban? What I want to do is that if there is only one item selected then display something, if there is more than two then ...
user avatar
  • 329
0 votes
2 answers
128 views

Scriban Rendering Parameters - how to get the value from Droplist?

I am trying to get the value from the Rendering Parameters in Scriban in order to render some new logic. Basically, I want to allow the content editors to choose what colour of the button they will ...
user avatar
  • 329
0 votes
1 answer
40 views

How to form a Page URL of wildcard item in scriban

I have created a variant to list down data source items using result variant selector and all these data items will need to point to wildcard content item .How to form URL of wildcard item in Scriban?
user avatar
0 votes
1 answer
227 views

Scriban - How to check if the value of certain general link field is null [duplicate]

Is there any way to check if the value of a field is empty or to be more precise value in general link field is empty in Scriban? Whenever I type the if keyword, it does not register it: Here is the ...
user avatar
  • 329
2 votes
1 answer
87 views

How can I do more complex loops in my Scriban templates?

I can loop through children like this: {{ for i_child in i_datasource.children}} But what if I only want the first 2, or if I want to skip the first 2 and take the next 3? Is this possible in scriban?...
user avatar
  • 18.8k
1 vote
1 answer
47 views

Is there any way to edit partial design using Scriban?

Is it possible to style the partial design using the scriban template. For example, I just made the new header partial design for my new site, and I am now clueless on how to style it. I have been ...
user avatar
  • 329
0 votes
2 answers
53 views

Using Sitecore link Manager in scriban script

I have a general link that is linking to an item in Sitecore. Path to linked item --> /sitecore/content/home/pageItemWithLayout I am using the below scriban script below to render the item link. &...
user avatar
  • 357
1 vote
2 answers
134 views

How to use orderby in Scriban template?

I have to list my upcoming events on the web page. I have created the data source item for holding all the events and each event has event date. I'm using Scriban to display all the events. My ...
user avatar
2 votes
1 answer
57 views

Disable webedit for sc_field in Scriban?

I have a multi-line text field that I am rendering using scriban. the Field Content is an address some building, some floor some street PO box somePOboxNumber somecountry How can I render this field ...
user avatar
  • 357
1 vote
1 answer
175 views

Is there a way to render scriban templates without the use of SXA Rendering Variants?

I would like to do some quick prototyping of scriban templates but have found constantly changing the rendering variant and refresh the page to be more time consuming than I would like. Is there a ...
user avatar
  • 16.4k
0 votes
0 answers
28 views

Pass the api model to components added in the scribans placeholder

We have created a custom scriban processor which gets the data from an external api and the model also got registered with scriban runtime. We have defined the scriban variant to use the custom ...
user avatar
1 vote
0 answers
24 views

Difference between scriban import and add

we are currently building a foundation in Sitecore SXA to process the external data using scriban context. Since we are to new scriban world and tried to understand how scriban processors are adding ...
user avatar
1 vote
3 answers
145 views

SXA Scriban Dynamic Placeholders

I am trying to render a dynamic placeholder with the Scriban as follows: {{ sc_placeholder 'section' }} and I would expect it to add a number to the key i.e. section-3, etc, but this is what I see as ...
user avatar
0 votes
1 answer
80 views

Search Result Listing Get index of an item using Scriban

I have a Search Result Listing Variant created using Scriban. This will render a card from each of the items got from the scope query. However, I want to get the index of items at the scriban template....
user avatar
  • 135
1 vote
0 answers
39 views

How to link static image asset from SXA using scriban

Sorry this is probably a dumb question but I can't seem to find anything related to it in google. Basically, I have a static image asset in my SXA Extension theme. e.g /sitecore/media library/...
user avatar
  • 135
2 votes
1 answer
240 views

How do you get value of item tag in scriban template

Sorry this is probably a dumb question but I am a bit stuck in here and I can't find suitable solutions in google. Basically I have an item or a page with a Tagging on it. But I can't seem to get the ...
user avatar
  • 135
4 votes
1 answer
443 views

Is there a way to parse Sitecore DateTime field type value in a particular Date or Time format directly in Scriban?

We are using SXA Rendering Variants with Scriban for our websites. In order to format the value of Sitecore field type DateTime in Scriban I am using `{{ sc_field i_item 'Date' [ [ 'format', 'd\nM,\...
user avatar
2 votes
1 answer
76 views

Handling multiple language versions of an Item in Scriban

Let's imagine I have an item with in three language versions: en, jp and es. My goal is to render a block which will display all 3 language versions of the item's 'Description' field. So, I would go ...
user avatar
0 votes
2 answers
291 views

Sitecore container with variants to change background color

I'd like to build a component in Sitecore that I can drag other components into when using Experience Accelerator, just like the out of the box container component. I'd also like to add variants on ...
user avatar
  • 15
0 votes
1 answer
122 views

Apply a CSS class to every alternative div using Sitecore SXA

I need to create an SXA component in which I need to apply a specific CSS class to each alternative div. The component should read the item from a multi-list and then render the HTML and apply a ...
user avatar
  • 123
3 votes
1 answer
372 views

How do you detect Edit Mode in the Experience Editor with Scriban?

Is there a function that I can use in the Scriban template to implement conditional logic based on the fact that the page is opened in the Experience Editor? Something like the below: <div class=&...
user avatar
3 votes
2 answers
937 views

Scriban template split string

I have a pipe-separated string www.test.com | www.test1.com I want to get just the first string before the pipe that is www.test.com. How can I do this in the scriban template?
user avatar
1 vote
1 answer
960 views

How can I iterate through a list of links with Scriban?

I've created a template in Sitecore, and one of the fields in my template allows me to select an existing Link List item. I also have a Scriban variant where the code loops through all the items ...
user avatar
  • 15
2 votes
1 answer
241 views

Is there a way to do Scriban partial templates?

In MVC there's the concept of Partial Views which helps refactor common code that can be reused by other Views. Is there a similar concept in SXA Scriban? Ideal example: List of Links Template: {{ for ...
user avatar
  • 4,735
0 votes
1 answer
273 views

Where can I find Scriban training or examples?

I'm trying to learn the basics of how to use Scriban to customize Sitecore SXA components. I'm having trouble finding any complete walk-throughs or training that provides a full example start to ...
user avatar
  • 15
3 votes
1 answer
186 views

Pipe expression destination `string.empty` is not a valid function

I'm trying to do something like {{ "" | string.empty }} and get Pipe expression destination 'string.empty' is not a valid function I can see it is available here though https://github.com/...
user avatar
  • 4,735
1 vote
1 answer
272 views

Sitecore scriban how to fetch linked item from it's linked sub item?

I have a requirement to fetch the linked item from its linked sub item along with some linked item from the parent item's field. Below is the scenario. I have a "Landing Page" In the "...
user avatar
0 votes
1 answer
90 views

Re-use the scriban template

Is there a way we can reuse a scriban template? I have a PromoBlock scriban template and I need to re-use that in the PromoHero and apply the Css Class to make it behave differently This is the ...
user avatar
1 vote
1 answer
329 views

Retrieving the href value of a Link field of Link item in scriban [duplicate]

I am trying to read the url value of Link field of Link item, append it with a query string and render the same as link. Below scriban does not work for the same. Any help please? {{ for i_child in (...
user avatar
2 votes
1 answer
776 views

How do you count the number of children in a Scriban template?

Given a page or item, how do I count the number of children? {{ i_page.children }}
user avatar
  • 16.4k
2 votes
1 answer
492 views

How to get Media URL with custom width and media protection hash using Scriban

I need separate image fields for mobile and desktop and trying to render it using Scriban in picture tag as below. Current Scriban code: <picture> <source srcset="{{ i_item....
user avatar
  • 1,949
0 votes
1 answer
168 views

DisableWebEdit in a Scriban template

Is there a way we can use DisableWebEdit=true in a Scriban template?. Like on a cshtml page we can use <title>@Html.Sitecore().Field("Title", Sitecore.Context.Item, new { ...
user avatar
1 vote
1 answer
2k views

Null checks in Scriban

I want to check for null values in Scriban. {{ if (o_model.address.id) }} <div style="text-align: center;"><h5>Address {{ o_model.address.id}}</h5><br /></div> ...
user avatar
4 votes
1 answer
797 views

Using Model in Scriban template

Is it possible to use the current Model in Scriban? I have a CutomHeroViewModel public class CustomHeroViewModel : VariantsRenderingModel { public string HeroTitle { get; set; } public string ...
user avatar
1 vote
0 answers
78 views

Is there a way to access all of a page's components?

I want to create a custom scriban Processor and I need to access all of the renderings that have been put on the page. Is there a way to access that data?
user avatar
  • 117
2 votes
1 answer
319 views

Customize Link rendering variant to append query string parameters

I want to customize an SXA link component with a rendering variant that appends query string parameters to the link based on fields on the page item. I'm using a Scriban template something like this: ...
user avatar
5 votes
2 answers
3k views

Accessing Link Field Values in a Scriban Template

I am using a Scriban template in Sitecore 9.3 with SXA and am attempting to render a link field. While the sc_link function reliably generates the URL, I cannot seem to find a way to access any other ...
user avatar
  • 591
2 votes
1 answer
868 views

Is there a way to get a user object in Scriban?

I was trying to display user information inside a Scriban template (SXA variant). I managed to write a context function that gives me the full name of the user (or any profile property I put in ...
user avatar
  • 19.1k
3 votes
1 answer
645 views

How can I use Sitecore Rules in Scriban templates in SXA 9.3

In SXA 9.3 we have the possibility of using Scriban Templates. I wonder if there is a possibility to use Sitecore rules engine inside of those templates. Let say that I would like to render part of ...
user avatar