From ec459e9ba5118fdb7b58aa2dc926494f1bc83acb Mon Sep 17 00:00:00 2001 From: Nate Jones Date: Mon, 18 Mar 2013 12:41:09 -0700 Subject: [PATCH] add support for //include --- bin/djsd | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/djsd b/bin/djsd index 43cf413..23c3a4d 100755 --- a/bin/djsd +++ b/bin/djsd @@ -36,10 +36,20 @@ dotjs = Class.new(WEBrick::HTTPServlet::AbstractServlet) do paths.shift end - body = "// dotjs is working! //\n" + tempbody = '' files.each do |file| - body << File.read(file) + "\n" if File.file?(file) + tempbody << File.read(file) + "\n" if File.file?(file) + end + + body = "// dotjs is working! //\n" + + # search for // include and include contents of file + tempbody.split("\n").each do |line| + body << line + "\n" + line.scan(/\/\/ *include +(\S*)/) do |file| + body << File.read(file[0]) + "\n" if File.file?(file[0]) + end end body