I now have the following working in javascript files to pull in others:
//= require <src>
Next up will be //= require_tree <path>
This also means that I finally figured out my named regexp's from yesterday. It basically boiled down to storing the results in a map. For example:
// Match ^//= require(_tree)? (.*)$ r, err := regexp.Compile(`^//=[[:blank:]]*require(?P<tree>_tree)?[[:blank:]]+(?P<argument>.*)$`) if err != nil { return src, err } sm := r.FindStringSubmatch(string(line)) m := make(map[string]string) if len(sm) > 0 { // Take each match and associate it with the named match for i, name := range r.SubexpNames() { // Don't include non-matches if sm[i] != "" { m[name] = sm[i] } } }
In looking at it just now, I changed the first [[:blank:]] to be optional. Seems like that will give less "WTF?" moments when using it if a space is forgotten.