Object
Processes special webgen tags to provide dynamic content.
webgen tags are an easy way to add dynamically generated content to websites, for example menus or breadcrumb trails.
Replace all webgen tags in the content of context with the rendered content.
# File lib/webgen/contentprocessor/tags.rb, line 24 24: def call(context) 25: replace_tags(context) do |tag, param_string, body| 26: log(:debug) { "Replacing tag #{tag} with data '#{param_string}' and body '#{body}' in <#{context.ref_node}>" } 27: process_tag(tag, param_string, body, context) 28: end 29: context 30: end
Process the tag and return the result. The parameter params needs to be a Hash holding all needed and optional parameters for the tag or a parameter String in YAML format and body is the optional body for the tag. context needs to be a valid Webgen::Context object.
# File lib/webgen/contentprocessor/tags.rb, line 35 35: def process_tag(tag, params, body, context) 36: result = '' 37: processor = processor_for_tag(tag) 38: if !processor.nil? 39: params = if params.kind_of?(String) 40: processor.create_tag_params(params, context.ref_node) 41: else 42: processor.create_params_hash(params, context.ref_node) 43: end 44: 45: processor.set_params(params) 46: result, process_output = processor.call(tag, body, context) 47: processor.set_params(nil) 48: result = call(context.clone(:content => result)).content if process_output 49: else 50: raise Webgen::RenderError.new("No tag processor for '#{tag}' found", self.class.name, 51: context.dest_node, context.ref_node) 52: end 53: result 54: end
Return the tag processor for tag or nil if tag is unknown.
# File lib/webgen/contentprocessor/tags.rb, line 156 156: def processor_for_tag(tag) 157: map = website.config['contentprocessor.tags.map'] 158: klass = if map.has_key?(tag) 159: map[tag] 160: elsif map.has_key?(:default) 161: map[:default] 162: else 163: nil 164: end 165: klass.nil? ? nil : website.cache.instance(klass) 166: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.