Class: Glinda::Site::Context
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Template
included, #markdown, #to_html
Constructor Details
#initialize(ctx = {}, config = {}, path = "/", env = {}) ⇒ Context
Returns a new instance of Context.
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/glinda.rb', line 213
def initialize ctx = {}, config = {}, path = "/", env = {}
@config, @context, @path, @env = config, ctx, path, env
@articles = Site.articles(@config[:ext]).reverse.map do |a|
Article.new(a, @config)
end
ctx.each do |k, v|
meta_def(k) { ctx.instance_of?(Hash) ? v : ctx.send(k) }
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &blk) ⇒ Object
243
244
245
|
# File 'lib/glinda.rb', line 243
def method_missing m, *args, &blk
@context.respond_to?(m) ? @context.send(m, *args, &blk) : super
end
|
Instance Attribute Details
Returns the value of attribute env.
211
212
213
|
# File 'lib/glinda.rb', line 211
def env
@env
end
|
Instance Method Details
#render(page, type) ⇒ Object
232
233
234
235
|
# File 'lib/glinda.rb', line 232
def render page, type
content = to_html page, @config
type == :html ? to_html(:layout, @config, &Proc.new { content }) : send(:"to_#{type}", page)
end
|
224
225
226
|
# File 'lib/glinda.rb', line 224
def tag_list
@tag_list ||= Site.tag_list(@config[:ext])
end
|
228
229
230
|
# File 'lib/glinda.rb', line 228
def title
@config[:title]
end
|
#to_xml(page) ⇒ Object
Also known as:
to_atom
237
238
239
240
|
# File 'lib/glinda.rb', line 237
def to_xml page
xml = Builder::XmlMarkup.new(:indent => 2)
instance_eval File.read("#{Paths[:templates]}/#{page}.builder")
end
|