HakubJozak / railroad_tie

Rails application template divided into sub-templates.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Railroad Tie

I like the idea of application templates in Rails but having everything in one file is a big mess so I decided to divide it into smaller chunks. Since I haven’t been able to figure out any “standard” or “better” way how to do it, here is my solution - the sub_template method - just put it to your template.rb and use it (see pre-requisities). Do you know some better way how to do it? Please let me know!

Example

if template.starts_with?('../') or template.starts_with?('./')
  raise "Please specify the '-m' parameter with full path."
end

def sub_template(name)
  code = File.new(name).readlines.join
  self.instance_eval(code)
end

template_root = File.dirname(File.expand_path(template))
sub_template(template_root + '/db.rb')

Pre-requisities:

  • Tested on Rails 2.3.5

  • specify the ‘-m’ option with full path and do not to use some remote repository)

About

Rails application template divided into sub-templates.


Languages

Language:Ruby 100.0%