Class: SpudPagePartial
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SpudPagePartial
- Defined in:
- app/models/spud_page_partial.rb
Instance Method Summary collapse
- #content_processed ⇒ Object
- #content_processed=(content) ⇒ Object
- #maintain_revisions ⇒ Object
- #postprocess_content ⇒ Object
- #symbol_name ⇒ Object
- #update_symbol_name ⇒ Object
- #update_taglist ⇒ Object
Instance Method Details
#content_processed ⇒ Object
43 44 45 46 47 48 |
# File 'app/models/spud_page_partial.rb', line 43 def content_processed if read_attribute(:content_processed).blank? self.update_column(:content_processed, postprocess_content) end return read_attribute(:content_processed) end |
#content_processed=(content) ⇒ Object
39 40 41 |
# File 'app/models/spud_page_partial.rb', line 39 def content_processed=(content) write_attribute(:content_processed,content) end |
#maintain_revisions ⇒ Object
50 51 52 53 54 55 56 57 |
# File 'app/models/spud_page_partial.rb', line 50 def maintain_revisions if self.changed.include?('content') revision = SpudPagePartialRevision.create(:spud_page_id => self.spud_page_id,:name => self.name,:format => self.format,:content => self.content) drop_old_revisions if Spud::Cms.max_revisions > 0 end return true end |
#postprocess_content ⇒ Object
20 21 22 23 24 |
# File 'app/models/spud_page_partial.rb', line 20 def postprocess_content template = Liquid::Template.parse(self.content) # Parses and compiles the template self.content_processed = template.render('page' => self.spud_page) end |
#symbol_name ⇒ Object
16 17 18 |
# File 'app/models/spud_page_partial.rb', line 16 def symbol_name return @symbol_name || self.name.parameterize.underscore end |
#update_symbol_name ⇒ Object
12 13 14 |
# File 'app/models/spud_page_partial.rb', line 12 def update_symbol_name self.symbol_name = self.name.parameterize.underscore end |
#update_taglist ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/models/spud_page_partial.rb', line 26 def update_taglist template = Liquid::Template.parse(self.content) # Parses and compiles the template self..all.each do |tag| tag.destroy end template.root.nodelist.each do |node| if !node.is_a?(String) && defined?(node.tag_name) && defined?(node.tag_value) self..create(:tag_name => node.tag_name,:value => node.tag_value) end end end |