-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconditionals.html.md.eco
39 lines (19 loc) · 1.12 KB
/
conditionals.html.md.eco
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
---
layout: "post"
title: "Conditionals"
date: 2014-09-28
description: "Conditional statements, <code>if</code> and <code>else</code> conditions, ternary operators, places that you can use conditionals"
---
If/else conditions are incredibly useful when you want a part of your code to depend on something else. This gives maximum flexibility to write the type of logic that meets your needs.
## Conditionals inside declarations
Supoort for `if` statements within a declaration. Less uses a slightly unconventional syntax, but works as expected.
<%- @code('Conditionals', 'basic') %>
## Ternary operators
Ternary operators allow for a single-line if/else test in the format of `x > 0 ? true : false`.
<%- @code('Conditionals', 'ternary') %>
## Interpolate conditionals inside properties
Ability to interpolate `if` statements inside property names.
<%- @code('Conditionals', 'property') %>
## Interpolate conditionals inside selectors
Ability to interpolate `if` statements inside selectors - there probably aren't a lot of use cases for using tests inside a selector but one never knows.
<%- @code('Conditionals', 'selector') %>