Skip to content

Instantly share code, notes, and snippets.

@bomberstudios
Created March 5, 2009 07:44
Show Gist options
  • Save bomberstudios/74251 to your computer and use it in GitHub Desktop.
Save bomberstudios/74251 to your computer and use it in GitHub Desktop.
a small sample of how to use ERB templates in your file without making your code fugly
require 'erb'
files = Dir.glob("*")
templates = DATA.read.split("---")
templates.each do |template|
ERB.new(template, nil, '%-').run
end
__END__
package {
public class Assets {
<% files.each do |path, var_name| -%>
[Embed(source="<%= path %>")]
public static var <%= var_name %>:Class;
<% end -%>
}
}
---
package {
public class AssetsTwo {
<% files.each do |path, var_name| -%>
[Embed(source="<%= path %>")]
public static var <%= var_name %>:Class;
<% end -%>
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment