Module: InlineTemplateLoader
- Defined in:
- lib/inline_template_loader.rb,
lib/inline_template_loader/version.rb
Constant Summary collapse
- VERSION =
"0.2.0"
Class Method Summary collapse
Class Method Details
.load(file = nil) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/inline_template_loader.rb', line 4 def self.load(file = nil) if file.nil? file = caller.first.split(':').first end templates = {} sym = nil app, data = ::IO.read(file).gsub("\r\n", "\n").split(/^__END__$/, 2) data.each_line do |line| if line =~ /^@@\s*(.*\S)\s*$/ sym = $1.to_sym else if sym unless templates[sym] templates[sym] = line else templates[sym] += line end end end end templates end |