|
1 | 1 | require 'fileutils'
|
2 | 2 | require 'haml'
|
3 |
| -require_relative '../activesupport_emulation_helper' |
| 3 | +require 'action_view' |
| 4 | + |
| 5 | +#require shared helper |
| 6 | +$shared_helper = Dir.glob('./dev_root/shared/helper/*.rb') |
| 7 | +$shared_helper.each do |file| require file end |
4 | 8 |
|
5 | 9 | module Generator
|
6 | 10 | class HamlGenerator
|
@@ -42,25 +46,33 @@ def write file, content
|
42 | 46 | end
|
43 | 47 | end
|
44 | 48 |
|
45 |
| - # TODO include shared/helper dynamic |
46 |
| - # Dir.glob(File.join('.', 'dev_root', 'shared', 'helper', '*.rb'), &method(:require)) |
47 |
| - |
48 |
| - |
49 | 49 | # Calls to "render" can take a context object that will be accessible from the templates.
|
50 | 50 | class Context
|
51 | 51 | # Any properties of this object are available in the Haml templates.
|
52 | 52 | attr_reader :example_boolean
|
53 | 53 |
|
54 |
| - include ActivesupportEmulationHelper |
| 54 | + include ActionView::Helpers |
55 | 55 |
|
56 |
| - #Dir.glob(File.join('dev_root', 'shared', 'helper', '*.rb'), &method(:include)) |
| 56 | + $shared_helper.each do |path| |
| 57 | + file_without_ext = path.split('/')[-1].split('.').first |
| 58 | + module_name = file_without_ext.classify |
| 59 | + STDERR.puts 'loading helper -> '+module_name |
| 60 | + include module_name.constantize |
| 61 | + end |
57 | 62 |
|
58 | 63 | def initialize(example_boolean, scope, options, input_folder, output_folder)
|
59 | 64 | @example_boolean = example_boolean
|
60 | 65 | @scope = scope
|
61 | 66 | @options = options
|
62 | 67 | @input_folder = input_folder
|
63 | 68 | @output_folder = output_folder
|
| 69 | + Dir.glob("./#{input_folder}/helper/*.rb").each do |path| |
| 70 | + require path |
| 71 | + file_without_ext = path.split('/')[-1].split('.').first |
| 72 | + module_name = file_without_ext.classify |
| 73 | + STDERR.puts 'loading project helper -> '+module_name |
| 74 | + self.class.send(:include, module_name.constantize) |
| 75 | + end |
64 | 76 | end
|
65 | 77 |
|
66 | 78 | # This function is no different from the "copyright_year" function above. It just uses some
|
|
0 commit comments