bin/nilac in nilac-0.0.4.2.5 vs bin/nilac in nilac-0.0.4.2.6
- old
+ new
@@ -1971,10 +1971,36 @@
return modified_file_contents
end
+ def compile_ternary_if(input_file_contents)
+
+ possible_ternary_if = input_file_contents.reject{|element| !element.include?("if")}
+
+ possible_ternary_if = possible_ternary_if.reject {|element| !element.include?("then")}
+
+ possible_ternary_if.each do |statement|
+
+ statement_extract = statement[statement.index("if")..statement.index("end")+2]
+
+ condition = statement_extract.split("then")[0].split("if")[1].lstrip.rstrip
+
+ true_condition = statement_extract.split("then")[1].split("else")[0].lstrip.rstrip
+
+ false_condition = statement_extract.split("else")[1].split("end")[0].lstrip.rstrip
+
+ replacement_string = "#{condition} ? #{true_condition} : #{false_condition}"
+
+ input_file_contents[input_file_contents.index(statement)] = input_file_contents[input_file_contents.index(statement)].sub(statement_extract,replacement_string)
+
+ end
+
+ return input_file_contents
+
+ end
+
def compile_inline_conditionals(input_file_contents, temporary_nila_file)
conditionals = [/( if )/, /( while )/, /( unless )/, /( until )/]
plain_conditionals = [" if ", " while ", " unless ", " until "]
@@ -2933,12 +2959,14 @@
return input_block
end
- file_contents, rejected_lines = ignore_statement_modifiers(input_file_contents)
+ file_contents = compile_ternary_if(input_file_contents)
+ file_contents, rejected_lines = ignore_statement_modifiers(file_contents)
+
file_contents = replace_unless_until(file_contents)
file_contents = compile_regular_if(file_contents, temporary_nila_file)
file_contents = compile_regular_while(file_contents, temporary_nila_file)
@@ -3743,10 +3771,10 @@
return remaining_string[0...remaining_string.length-path_finder]
end
-nilac_version = "0.0.4.2.5"
+nilac_version = "0.0.4.2.6"
opts = Slop.parse do
on :c, :compile=, 'Compile Nila File', as:Array, delimiter:":"
on :h, :help, 'Help With Nilac' do