#!/usr/bin/env ruby require "liquidscript" if ARGV.length < 1 puts "Usage: #{File.basename($0)} infile [outfile]" exit 1 end infile = ARGV.shift outfile = ARGV.shift || infile.gsub(/\.liq\Z/, ".js") File.open(infile, "r") do |f| begin out = Liquidscript.compile(f.read) File.open(outfile, "w") { |o| o.write out } rescue StandardError => e $stderr.puts "ERROR: #{e.class}: #{e.message}" $stderr.puts e.backtrace[0..5].map { |s| "\t#{s.gsub(/^.*?\/lib\/liquidscript\//, "")}" }.join("\n") end end