Created
March 5, 2009 07:44
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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