Permalink
Browse files

Update with comments

  • Loading branch information...
1 parent 86bbb27 commit d527771a1b760601c5c43b7d49df41d694936574 @jordansissel committed Feb 21, 2012
Showing with 9 additions and 0 deletions.
  1. +9 −0 where-art-thou/whereareyou/templates/example.erb
@@ -1,10 +1,19 @@
<%=
+ # Split modulepath by ":"
scope.lookupvar("settings::modulepath").split(":").collect do |path|
+ # Fully resolve the path so things like '.' become full path names like
+ # /path/to/modules
expandedpath = File.expand_path(path)
+
+ # Check if this file (this template file) is in the path being examined
if __FILE__.start_with?(expandedpath)
+ # If it is, return the current module path (unexpanded, and the path
+ # in it relative to this template file
[path, __FILE__.gsub(expandedpath + "/", "")]
else
+ # Otherwise return nil
nil
end
+ # Then select the first non-nil entry
end.select { |f| !f.nil? }.first
%>

0 comments on commit d527771

Please sign in to comment.