Follow

The Basics of StoreYa Theme Editor Syntax


1. Adding a code to a page is done by using the @ character. The @ character starts inline expressions, single statement blocks and multi-statement blocks.

2. You enclose code blocks in braces. A code block includes one or more code statements and is enclosed in braces.

3. Inside a block, each code statement must end with a semicolon. Inside a code block, each complete code statement must end with a semicolon. Inline expressions don't end with a semicolon.

<!-- Single statement blocks  -->
@{ var total = 7; }
@{ var myMessage = "Hello World"; }

<!-- Inline expressions -->
<p>The value of your account is: @total </p>
<p>The value of myMessage is: @myMessage</p>

<!-- Multi-statement block -->
@{
    var greeting = "Welcome to our site!";
    var weekDay = DateTime.Now.DayOfWeek;
    var greetingMessage = greeting + " Today is: " + weekDay;
}
<p>The greeting is: @greetingMessage</p>

 

4. Variables are used to store values

<!-- Storing a string -->
@{ var welcomeMessage = "Welcome, new members!"; }
<p>@welcomeMessage</p>
<!-- Storing a date -->
@{ var year = DateTime.Now.Year; }
<!-- Displaying a variable -->
<p>Welcome to our new members who joined in @year!</p>

 

5. You enclose literal string values in double quotation marks
6. Code is case sensitive
7. Code can be written in a way that makes decisions

<!-- Logic block -->
@{
     var price = product.Price;
     if(price == "0")
     {
        price = "Contact us";
     }
}
<p>Price: @price</p>
8. You can run loops based on data provided in Model object
<!-- Loop block -->
@foreach (var product in Model.Products)
{
    Product Name: @product.Name <br/>
}
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk