require 'active_support' require 'active_support/core_ext/hash' module Fortitude module MethodTemplates class SimpleCompiledTemplate class << self def template(name) @templates ||= { } @templates[name] ||= new(File.join(File.dirname(__FILE__), "#{name}.rb.smpl")) end end def initialize(source_file) @source_file = source_file method_text_lines = [ "def result", " output = ''" ] pending_fixed_strings = [ ] File.read(source_file).split(/\r\n|\r|\n/).each do |line| needs_end = false line = line.chomp if line =~ /^(.*)\#\s*\:if\s*(.*?)\s*$/i if pending_fixed_strings.length > 0 method_text_lines << " output << < 0 method_text_lines << " output << <