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
49 50 51 52 53 54 55 56 |
# File 'app/models/spud_page_partial.rb', line 49 def content_processed if read_attribute(:content_processed).blank? self.update_column(:content_processed, postprocess_content) end template = Liquid::Template.parse(read_attribute(:content_processed)) # Parses and compiles the template return template.render('page' => self.spud_page) end |
#content_processed=(content) ⇒ Object
45 46 47 |
# File 'app/models/spud_page_partial.rb', line 45 def content_processed=(content) write_attribute(:content_processed,content) end |
#maintain_revisions ⇒ Object
58 59 60 61 62 63 64 65 |
# File 'app/models/spud_page_partial.rb', line 58 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
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/models/spud_page_partial.rb', line 19 def postprocess_content rendererClass = Spud::Core.renderer(self.format) if rendererClass renderer = rendererClass.new() self.content_processed = renderer.render self.content else self.content_processed = content end # template = Liquid::Template.parse(self.content) # Parses and compiles the template # self.content_processed = template.render('page' => self.spud_page) end |
#symbol_name ⇒ Object
15 16 17 |
# File 'app/models/spud_page_partial.rb', line 15 def symbol_name return @symbol_name || self.name.parameterize.underscore end |
#update_symbol_name ⇒ Object
11 12 13 |
# File 'app/models/spud_page_partial.rb', line 11 def update_symbol_name self.symbol_name = self.name.parameterize.underscore end |
#update_taglist ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/spud_page_partial.rb', line 32 def update_taglist template = Liquid::Template.parse(self.content) # Parses and compiles the template self..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 |