This plugin adds the ability to use ternary statements as property values in TurbineCSS.
Sample Use Cases:
- If it is a holiday change the colors and background to a holiday themes.
- If enviroment is in debug mode display special hidden elements.
Setup:
- Copy
ternary.php
into theplugins
folder of TurbineCSS. - Add
ternary
to plugin list:
@turbine
plugins:ternary
Usage:
Template: condition ? true : false
Basic Ex.
@constants
debug: true
#foo
display: $debug == true ? "block" : "none";
Result:
#foo { display: block; }
Advanced Ex.
#foo
color: date("Y") == 2017 ? "#87AE4F" : "#".date("Y")."BB";
Result for True:
#foo { color: #87AE4F; }
Result for False: (the "2018" part of the hex color code would be the evaluated year)
#foo { color: #2018BB; }