Questions tagged [scriban]

For questions related to the SXA Scriban templates.

Filter by
Sorted by
Tagged with
0
votes
0answers
14 views

Render the Link text of a Sitecore General Link field using scriban script in SXA [duplicate]

I have a template which has a General Link field CTA. Raw Value for CTA Field: <link text="Learn More" anchor="" linktype="internal" class="" title="&...
0
votes
1answer
23 views

Apply a CSS class to every alternative div using Sitecore SXA

I need to create a SXA component in which I need to apply a specific CSS class to each alternative div. The component should read item from a multilist and then render the HTML and apply a "...
3
votes
1answer
86 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=&...
3
votes
2answers
122 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?
1
vote
1answer
95 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 ...
2
votes
1answer
43 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 ...
0
votes
1answer
47 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 ...
3
votes
1answer
36 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/...
1
vote
1answer
49 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 "...
0
votes
1answer
37 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 ...
1
vote
1answer
48 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 (...
2
votes
1answer
215 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 }}
2
votes
1answer
170 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....
0
votes
1answer
47 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 { ...
0
votes
1answer
508 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> ...
2
votes
1answer
316 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 ...
1
vote
0answers
59 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?
2
votes
1answer
166 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: ...
5
votes
2answers
1k 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 ...
2
votes
1answer
448 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 ...
3
votes
1answer
408 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 ...