lib/faml/script_parser.rb in faml-0.2.9 vs lib/faml/script_parser.rb in faml-0.2.10

- old
+ new

@@ -26,30 +26,30 @@ def parse_script(text) if text[1] == '=' create_node(Ast::Text) { |t| t.text = text[2 .. -1].strip } else node = create_node(Ast::Script) - node.script = text[1 .. -1].lstrip - if node.script.empty? + script = text[1 .. -1].lstrip + if script.empty? syntax_error!('No Ruby code to evaluate') end - node.script += RubyMultiline.read(@line_parser, node.script) + node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n") node end end def parse_sanitized(text) case when text.start_with?('&==') create_node(Ast::Text) { |t| t.text = text[3 .. -1].lstrip } when text[1] == '=' || text[1] == '~' node = create_node(Ast::Script) - node.script = text[2 .. -1].lstrip - if node.script.empty? + script = text[2 .. -1].lstrip + if script.empty? syntax_error!('No Ruby code to evaluate') end - node.script += RubyMultiline.read(@line_parser, node.script) + node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n") node.preserve = text[1] == '~' node else create_node(Ast::Text) { |t| t.text = text[1 .. -1].strip } end @@ -63,14 +63,14 @@ t.escape_html = false end when text[1] == '=' || text[1] == '~' node = create_node(Ast::Script) node.escape_html = false - node.script = text[2 .. -1].lstrip - if node.script.empty? + script = text[2 .. -1].lstrip + if script.empty? syntax_error!('No Ruby code to evaluate') end - node.script += RubyMultiline.read(@line_parser, node.script) + node.script = [script, *RubyMultiline.read(@line_parser, script)].join("\n") node.preserve = text[1] == '~' node else create_node(Ast::Text) do |t| t.text = text[1 .. -1].lstrip