Class: SpudPagePartial

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/spud_page_partial.rb

Instance Method Summary collapse

Instance Method Details

#content_processedObject



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_revisionsObject



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_contentObject



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_nameObject



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_nameObject



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_taglistObject



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.spud_page_liquid_tags.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.spud_page_liquid_tags.create(:tag_name => node.tag_name,:value => node.tag_value)
		end
	end
end