Class: Vita::RenderingContext

Inherits:
Object
  • Object
show all
Includes:
Html
Defined in:
lib/vita/rendering_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Html

#h, #link_to

Constructor Details

#initialize(note) ⇒ RenderingContext

Returns a new instance of RenderingContext.



9
10
11
# File 'lib/vita/rendering_context.rb', line 9

def initialize(note)
  @note = note
end

Instance Attribute Details

#noteObject (readonly)

Returns the value of attribute note.



7
8
9
# File 'lib/vita/rendering_context.rb', line 7

def note
  @note
end

Instance Method Details

#content_htmlObject



17
18
19
20
21
22
23
24
# File 'lib/vita/rendering_context.rb', line 17

def content_html
  note.outlinks.reduce(note.html) { |html, link|
    html.sub(
      /(?<=\s)#{Regexp.quote(link.text)}\b/,
      link_to(link.text, link.to_note.path)
    )
  }
end

#gardenObject



13
14
15
# File 'lib/vita/rendering_context.rb', line 13

def garden
  note.garden
end

#get_bindingObject



30
31
32
# File 'lib/vita/rendering_context.rb', line 30

def get_binding
  binding
end


26
27
28
# File 'lib/vita/rendering_context.rb', line 26

def link_to_note(note)
  link_to note.title, note.path
end