Module: Awestruct::Textilable

Included in:
TextileFile
Defined in:
lib/awestruct/textilable.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



16
17
18
19
# File 'lib/awestruct/textilable.rb', line 16

def content
  context = site.engine.create_context(self)
  render(context)
end

#render(context) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/awestruct/textilable.rb', line 4

def render(context)
  rendered = ''
  # security and rendering restrictions
  # ex. site.textile = ['no_span_caps']
  restrictions = (site.textile || []).map { |r| r.to_sym }
  # a module of rule functions is included in RedCloth using RedCloth.send(:include, MyRules)
  # rule functions on that module are activated by setting the property site.textile_rules
  # ex. site.textile_rules = ['emoticons']
  rules = context.site.textile_rules ? context.site.textile_rules.map { |r| r.to_sym } : []
  RedCloth.new( context.interpolate_string( raw_page_content ), restrictions ).to_html(*rules)
end