Object
Create a template node for path.
# File lib/webgen/sourcehandler/template.rb, line 13 13: def create_node(path) 14: page = page_from_path(path) 15: super(path) do |node| 16: node.node_info[:page] = page 17: end 18: end
Return the default template for the directory node dir. If the template node is not found, the parent directories are searched.
# File lib/webgen/sourcehandler/template.rb, line 52 52: def default_template(dir_node, lang) 53: template_node = dir_node.resolve(website.config['sourcehandler.template.default_template'], lang) 54: if template_node.nil? 55: if dir_node.is_root? 56: log(:warn) { "No default template in root directory found!" } 57: else 58: template_node = default_template(dir_node.parent, lang) 59: end 60: end 61: template_node 62: end
Return the template chain for node.
# File lib/webgen/sourcehandler/template.rb, line 21 21: def templates_for_node(node, lang = node.lang) 22: cached_template = (website.cache.volatile[[node.alcn, :templates]] ||= {}) 23: if cached_template[lang] 24: template_node = cached_template[lang] 25: elsif node['template'].kind_of?(String) 26: template_node = node.resolve(node['template'], lang) 27: if template_node.nil? 28: log(:warn) { "Specified template '#{node['template']}' for <#{node}> not found, using default template!" } 29: template_node = default_template(node.parent, lang) 30: end 31: cached_template[lang] = template_node 32: elsif node.meta_info.has_key?('template') && node['template'].nil? 33: template_node = cached_template[lang] = nil 34: else 35: log(:info) { "Using default template in language '#{lang}' for <#{node}>" } 36: template_node = default_template(node.parent, lang) 37: if template_node == node && !node.parent.is_root? 38: template_node = default_template(node.parent.parent, lang) 39: end 40: cached_template[lang] = template_node 41: end 42: 43: if template_node.nil? 44: [] 45: else 46: (template_node == node ? [] : templates_for_node(template_node, lang) + [template_node]) 47: end 48: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.