Skip to content
This repository

add support for //include #78

Open
wants to merge 1 commit into from

2 participants

Nate Jones Björn
Nate Jones

This change adds support for including dotjs scripts. For example, given the following files:

foo.js

alert('foo');

bar.com.js

// include foo.js

Then fetching the js for bar.com would result in:

// include foo.js
alert('foo');

This sort of addresses #27.

Björn

I like this. It's nice for including libraries since you can't use $.getScript().
+1 :)

Nate Jones

Rebased to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 2 authors.

Aug 19, 2013
Nate Jones add support for //include ec459e9
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 12 additions and 2 deletions. Show diff stats Hide diff stats

  1. 14  bin/djsd
14  bin/djsd
@@ -36,10 +36,20 @@ dotjs = Class.new(WEBrick::HTTPServlet::AbstractServlet) do
36 36
       paths.shift
37 37
     end
38 38
 
39  
-    body = "// dotjs is working! //\n"
  39
+    tempbody = ''
40 40
 
41 41
     files.each do |file|
42  
-      body << File.read(file) + "\n" if File.file?(file)
  42
+      tempbody << File.read(file) + "\n" if File.file?(file)
  43
+    end
  44
+
  45
+    body = "// dotjs is working! //\n"
  46
+
  47
+    # search for // include <js file> and include contents of file
  48
+    tempbody.split("\n").each do |line|
  49
+      body << line + "\n"
  50
+      line.scan(/\/\/ *include +(\S*)/) do |file|
  51
+        body << File.read(file[0]) + "\n" if File.file?(file[0])
  52
+      end
43 53
     end
44 54
 
45 55
     body
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.