Class: SpudSnippet
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SpudSnippet
- Defined in:
- app/models/spud_snippet.rb
Instance Method Summary collapse
- #content_processed ⇒ Object
- #content_processed=(content) ⇒ Object
- #postprocess_content ⇒ Object
- #update_taglist ⇒ Object
Instance Method Details
#content_processed ⇒ Object
21 22 23 24 25 26 |
# File 'app/models/spud_snippet.rb', line 21 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
17 18 19 |
# File 'app/models/spud_snippet.rb', line 17 def content_processed=(content) write_attribute(:content_processed,content) end |
#postprocess_content ⇒ Object
12 13 14 15 |
# File 'app/models/spud_snippet.rb', line 12 def postprocess_content template = Liquid::Template.parse(self.content) # Parses and compiles the template self.content_processed = template.render() end |
#update_taglist ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/spud_snippet.rb', line 29 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 |