Sha256: 36028aa19410f8c91ed8590022e289b9a43e68b28706680f63da24a999ac2f71

Contents?: true

Size: 565 Bytes

Versions: 3

Compression:

Stored size: 565 Bytes

Contents

class PagePart < ActiveRecord::Base
  belongs_to :page

  validates_presence_of :name
  validates_uniqueness_of :name, :scope => :page_id

  def render(drops_or_context, wrap = false)
    template = Liquid::Template.parse(body)
    result = tracker.cleanup template.render(drops_or_context, :registers => {:tracker => tracker})
    main? ? result : (wrap ? "<% content_for :#{name} do %>#{result}<% end %>" : result)
  end

  def tracker
    @tracker ||= PufferPages::Liquid::Tracker.new
  end

  def main?
    name == PufferPages.primary_page_part_name
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
puffer_pages-0.0.9 app/models/page_part.rb
puffer_pages-0.0.8 app/models/page_part.rb
puffer_pages-0.0.7 app/models/page_part.rb