Class: Pakyow::Generator::Processor
- Inherits:
-
Object
- Object
- Pakyow::Generator::Processor
- Includes:
- Support::Pipeline
- Defined in:
- lib/pakyow/generator.rb
Constant Summary collapse
- PATH_VAR_REGEX =
/%([^}]*)%/
Instance Method Summary collapse
Instance Method Details
#populate_path(file) ⇒ Object
131 132 133 134 135 |
# File 'lib/pakyow/generator.rb', line 131 def populate_path(file) file.logical_path.scan(PATH_VAR_REGEX).each do |match| file.logical_path.gsub!("%#{match[0]}%", file.context.send(match[0].to_sym)) end end |
#process_erb(file) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/pakyow/generator.rb', line 110 def process_erb(file) if ::File.extname(file.logical_path) == ".erb" file.logical_path = ::File.join( ::File.dirname(file.logical_path), ::File.basename(file.logical_path, ".erb") ) erb = if RUBY_VERSION.start_with?("2.5") ERB.new(file.content, nil, "%<>-") else ERB.new(file.content, trim_mode: "%-") end file.content = erb.result( file.context.instance_eval { binding } ) end end |