Class: Fronton::Page

Inherits:
Object
  • Object
show all
Defined in:
lib/fronton/page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, url) ⇒ Page

Returns a new instance of Page.



8
9
10
11
# File 'lib/fronton/page.rb', line 8

def initialize(name, url)
  @name   = name
  @url    = url
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/fronton/page.rb', line 6

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



6
7
8
# File 'lib/fronton/page.rb', line 6

def url
  @url
end

Instance Method Details

#contentObject



13
14
15
# File 'lib/fronton/page.rb', line 13

def content
  Tilt.new(template_path, template_options).render(Fronton::Contexts::Tilt.new)
end

#exist?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/fronton/page.rb', line 21

def exist?
  !template_path.nil?
end

#saveObject



17
18
19
# File 'lib/fronton/page.rb', line 17

def save
  File.open(save_path, 'w') { |f| f.write(content) }
end