Class: Octopress::Ink::Assets::Template
- Defined in:
- lib/octopress-ink/assets/template.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Asset
Instance Attribute Summary collapse
-
#pages ⇒ Object
readonly
Returns the value of attribute pages.
Attributes inherited from Asset
#base, #dir, #exists, #file, #plugin, #replacement, #root
Instance Method Summary collapse
- #add ⇒ Object
- #info ⇒ Object
-
#initialize(*args) ⇒ Template
constructor
A new instance of Template.
- #new_page(data = {}) ⇒ Object
- #page_exists?(page) ⇒ Boolean
Methods inherited from Asset
#asset_info, #content, #copy, #data, #destination, #disable, #disabled?, #ext, #filename, #is_disabled, #path, #payload, #read, #remove_jekyll_asset, #replaced?
Constructor Details
#initialize(*args) ⇒ Template
Returns a new instance of Template.
7 8 9 10 11 |
# File 'lib/octopress-ink/assets/template.rb', line 7 def initialize(*args) super(*args) @pages = [] @existing_pages = {} end |
Instance Attribute Details
#pages ⇒ Object (readonly)
Returns the value of attribute pages.
5 6 7 |
# File 'lib/octopress-ink/assets/template.rb', line 5 def pages @pages end |
Instance Method Details
#add ⇒ Object
13 |
# File 'lib/octopress-ink/assets/template.rb', line 13 def add; end |
#info ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/octopress-ink/assets/template.rb', line 15 def info = " - #{asset_info}\n" unless disabled? self.pages.each do |page| if existing_page = @existing_pages[page.url] << " #{page.url.ljust(33)} Disabled: /#{existing_page.path} already exists\n" else << " #{page.url}\n" end end end end |
#new_page(data = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/octopress-ink/assets/template.rb', line 31 def new_page(data={}) return if disabled? page = Ink::Page.new(Octopress.site, File.dirname(self.path), '.', File.basename(self.path)) page.data.merge!(data) page.plugin = plugin page.asset = self self.pages << page if existing_page = page_exists?(page) if existing_page.respond_to?(:plugin) @replacement = existing_page.plugin.name else @existing_pages[existing_page.url] = existing_page end false else page end end |
#page_exists?(page) ⇒ Boolean
51 52 53 |
# File 'lib/octopress-ink/assets/template.rb', line 51 def page_exists?(page) Octopress.site.pages.find {|p| p.url == page.url} end |