Sha256: b70ea57e851f649637711bad969e25e5079d27524448c13f003332f9521a8a11
Contents?: true
Size: 1.83 KB
Versions: 10
Compression:
Stored size: 1.83 KB
Contents
module Nanoc # A Nanoc::Template represents a template, which can be used for creating # new pages. Pages don't necessary have to be created using templates, but # they can be useful for generating pages where you only have to "fill in # the blanks". class Template # The Nanoc::Site this template belongs to. attr_accessor :site # The name of this template. attr_reader :name # The raw content a page created using this template will have. attr_reader :page_content # A hash containing the attributes a page created using this template will # have. attr_reader :page_attributes # Creates a new template. # # +name+:: The name of this template. # # +page_content+:: The raw content a page created using this template will # have. # # +page_attributes+:: A hash containing the attributes a page created # using this template will have. def initialize(page_content, page_attributes, name) @page_content = page_content @page_attributes = page_attributes.clean @name = name end # Saves the template in the database, creating it if it doesn't exist yet # or updating it if it already exists. Tells the site's data source to # save the template. def save @site.data_source.loading do @site.data_source.save_template(self) end end # Renames the template. Tells the site's data source to rename the # template. def move_to(new_name) @site.data_source.loading do @site.data_source.move_template(self, new_name) end end # Deletes the template. Tells the site's data source to delete the # template. def delete @site.data_source.loading do @site.data_source.delete_template(self) end end end end
Version data entries
10 entries across 10 versions & 1 rubygems