Tholp's bespoke website generator
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add `if` macro

Tholp 961cdff4 dbcadd5c

+22 -3
+8 -1
src/macros/mod.rs
··· 111 111 takes_block: true, 112 112 min_args: 0, 113 113 max_args: 0 114 - } 114 + }, 115 + Macro { 116 + symbol: "if", 117 + expansion: macro_if, 118 + takes_block: true, 119 + min_args: 0, // lua block with nil result is just blank 120 + max_args: 1 121 + }, 115 122 ];
+14
src/macros/simple_blocks.rs
··· 75 75 t.pre_proccessed = true; 76 76 } 77 77 return out; 78 + } 79 + 80 + pub fn macro_if ( 81 + _origin_index: usize, 82 + _origin_line: usize, 83 + _context: &mut Project, 84 + _skid_context: &mut SkidContext, 85 + args: &Vec<String>, 86 + scope: &[Token], 87 + ) -> Vec<Token> { 88 + if args.len() == 0 || args[0] == "false" { // pretty much everything is truthy https://www.lua.org/pil/2.2.html 89 + return Vec::new(); 90 + } 91 + return scope.to_vec(); 78 92 }
-2
src/stringtools.rs
··· 80 80 } 81 81 } 82 82 else { 83 - println!("was none : ("); 84 83 arg.push('$'); 85 84 } 86 85 continue; ··· 97 96 } 98 97 99 98 if !entered || !exited_cleanly { 100 - println!("was none but very bad : ("); 101 99 return None; 102 100 } 103 101 return Some((args, consumed));