Class Webgen::SourceHandler::Template
In: lib/webgen/sourcehandler/template.rb
Parent: Object
Error RenderError CommandNotFoundError LoadError NodeCreationError ::Rake::TaskLib WebgenTask Context\n[lib/webgen/context.rb\nlib/webgen/context/nodes.rb\nlib/webgen/context/render.rb\nlib/webgen/context/tags.rb] Node Tree FileSystem Sitemap Coderay Sitemap IncludeFile Langbar BreadcrumbTrail TikZ Menu Feed Copy Virtual Sitemap Directory Page Fragment Template Metainfo Memory Resource Tags Fragments Website Tidy Head Kramdown Less Xmllint Blocks Helpers Configuration Comparable Language Path StandardError CmdParse::CommandParser CommandParser CmdParse::Command RunCommand WebguiCommand CreateCommand ApplyCommand ExecuteCommand Link Date Relocatable Metainfo WebsiteAccess Main Loggable OutputPathHelpers ::Kramdown::Converter::Html KramdownHtmlConverter Cache Blackboard WebsiteManager Logger Page ProxyNode Utils TarArchive Stacked FileSystem RDoc Sass Erb RDiscount Erubis Haml Maruku Builder RedCloth AccessHash lib/webgen/cache.rb lib/webgen/error.rb lib/webgen/languages.rb lib/webgen/blackboard.rb lib/webgen/website.rb lib/webgen/tree.rb lib/webgen/websitemanager.rb lib/webgen/logger.rb lib/webgen/configuration.rb lib/webgen/context/tags.rb lib/webgen/path.rb lib/webgen/webgentask.rb lib/webgen/page.rb lib/webgen/node.rb lib/webgen/cli/run_command.rb lib/webgen/cli/utils.rb lib/webgen/cli/apply_command.rb lib/webgen/cli/webgui_command.rb lib/webgen/cli.rb lib/webgen/cli/create_command.rb Color CLI ClassMethods WebsiteAccess LanguageManager lib/webgen/output/filesystem.rb Output lib/webgen/common/sitemap.rb Common lib/webgen/tag/coderay.rb lib/webgen/tag/relocatable.rb lib/webgen/tag/menu.rb lib/webgen/tag/langbar.rb lib/webgen/tag/executecommand.rb lib/webgen/tag/breadcrumbtrail.rb lib/webgen/tag/metainfo.rb lib/webgen/tag/includefile.rb lib/webgen/tag/link.rb lib/webgen/tag/date.rb lib/webgen/tag/tikz.rb lib/webgen/tag/sitemap.rb Base Tag lib/webgen/sourcehandler/memory.rb lib/webgen/sourcehandler/metainfo.rb lib/webgen/sourcehandler/copy.rb lib/webgen/sourcehandler/directory.rb lib/webgen/sourcehandler.rb lib/webgen/sourcehandler/page.rb lib/webgen/sourcehandler/template.rb lib/webgen/sourcehandler/fragment.rb lib/webgen/sourcehandler/sitemap.rb lib/webgen/sourcehandler/virtual.rb lib/webgen/sourcehandler/feed.rb OutputPathHelpers Base SourceHandler lib/webgen/source/tararchive.rb lib/webgen/source/stacked.rb lib/webgen/source/resource.rb lib/webgen/source/filesystem.rb Source lib/webgen/contentprocessor/less.rb lib/webgen/contentprocessor/blocks.rb lib/webgen/contentprocessor/rdoc.rb lib/webgen/contentprocessor/sass.rb lib/webgen/contentprocessor/erb.rb lib/webgen/contentprocessor/rdiscount.rb lib/webgen/contentprocessor/tags.rb lib/webgen/contentprocessor/erubis.rb lib/webgen/contentprocessor/kramdown/html.rb lib/webgen/contentprocessor/haml.rb lib/webgen/contentprocessor/maruku.rb lib/webgen/contentprocessor/xmllint.rb lib/webgen/contentprocessor/kramdown.rb lib/webgen/contentprocessor/head.rb lib/webgen/contentprocessor/builder.rb lib/webgen/contentprocessor/tidy.rb lib/webgen/contentprocessor/redcloth.rb lib/webgen/contentprocessor/fragments.rb lib/webgen/contentprocessor.rb ContentProcessor Loggable Webgen dot/m_81_0.png

Source handler for handling template files in Webgen Page Format.

Methods

Included Modules

Webgen::WebsiteAccess Webgen::Loggable Base

Public Instance methods

Create a template node for path.

[Source]

    # 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.

[Source]

    # 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.

[Source]

    # 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

[Validate]