Class: RubyView::Context

Inherits:
Object
  • Object
show all
Includes:
DSL, Helpers, Helpers::Tag
Defined in:
lib/rubyview/context.rb

Instance Method Summary collapse

Methods included from Helpers::Tag

#div, #format_html_opts, #generate_tag, #h1, #img, #merge_classes, #p, #render_tag

Methods included from DSL

#container, #header, #image, #text

Constructor Details

#initializeContext

Returns a new instance of Context.



8
9
# File 'lib/rubyview/context.rb', line 8

def initialize
end

Instance Method Details

#call(file_path: nil, code: nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubyview/context.rb', line 11

def call(file_path: nil, code: nil)
  return puts 'you must pass in file path or code to func' if !file_path && !code
  @_rendered_content = ""
  template_content = if file_path
    template_path = File.join(Dir.pwd, path_to_template)
    File.read(template_path)
  else
    code
  end
  instance_eval(template_content)
  @_rendered_content
end