razor/conditional-control-structures

node v10.14.1
version: 1.0.0
endpointsharetweet
//////////////////////////////////////////////// // Razor-Express Conditional Control Structures examples. // https://github.com/DevelAx/RazorExpress/blob/master/docs/overview.md#conditionals-if-else-if-else-and-switch //////////////////////////////////////////////// const raz = require("raz@0.0.46");
//////////////////////////////////////////////// // `if/else` statements structure example. //////////////////////////////////////////////// var template = ` @{ var year = new Date().getFullYear(); } <div> @if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0){ <strong>@year is a leap year.</strong> } else{ <strong>@year is not a leap year.</strong> } </div>`; raz.compileSync({template});
//////////////////////////////////////////////// // `if/else` statements structure example. //////////////////////////////////////////////// template = ` @switch (new Date().getDay()) { case 0: var day = "Sunday"; break; case 1: day = "Monday"; break; case 2: day = "Tuesday"; break; case 3: day = "Wednesday"; break; case 4: day = "Thursday"; break; case 5: day = "Friday"; break; case 6: day = "Saturday"; } <strong>Today is @day</strong>`; raz.compileSync({template});
Loading…

no comments

    sign in to comment