Class: PartialCompiler::PartialReader

Inherits:
Object
  • Object
show all
Defined in:
lib/partial_compiler/partial_reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(original_string, file_called_from) ⇒ PartialReader

@path: Where the partial file is located

@locals: The locals set in the uncompiled file
@contents: The actual guts of the partial which will be placed in the compiled file
@indentation: The indentation on the line where 'render partial' is called


13
14
15
16
17
18
19
# File 'lib/partial_compiler/partial_reader.rb', line 13

def initialize original_string, file_called_from 
  code_to_eval = original_string.match(PartialCompiler.config[:regex_partial_eval_match])[1]
  path_to_partial, partial_name, @locals = execute_safe_ruby(code_to_eval)
  set_path(path_to_partial, partial_name, file_called_from)
  get_indentation(original_string)
  set_contents(@indentation)
end

Instance Attribute Details

#contentsObject

Returns the value of attribute contents.



6
7
8
# File 'lib/partial_compiler/partial_reader.rb', line 6

def contents
  @contents
end

#indentationObject

Returns the value of attribute indentation.



6
7
8
# File 'lib/partial_compiler/partial_reader.rb', line 6

def indentation
  @indentation
end

#localsObject

Returns the value of attribute locals.



6
7
8
# File 'lib/partial_compiler/partial_reader.rb', line 6

def locals
  @locals
end

#pathObject

Returns the value of attribute path.



6
7
8
# File 'lib/partial_compiler/partial_reader.rb', line 6

def path
  @path
end