class Webgen::Utils::TagParser
This class is used to parse a string for webgen tags and replace them with dynamically generated content. See replace_tags for more information.
Public Class Methods
new(prefix = nil)
click to toggle source
Create a new TagParser object, optionally providing a tag prefix.
# File lib/webgen/utils/tag_parser.rb, line 23 def initialize(prefix = nil) @start_re = /(\\*)\{#{prefix}(\w+)(::?)/ @end_re = /(\\*)\{#{prefix}(\w+)\}/ end
Public Instance Methods
parse_params(param_string, tag)
click to toggle source
Parse the parameter string and return the result.
# File lib/webgen/utils/tag_parser.rb, line 114 def parse_params(param_string, tag) YAML::load("--- #{param_string}") rescue ArgumentError, SyntaxError, YAML::SyntaxError => e raise Error.new("Could not parse parameter string '#{param_string}' for tag '#{tag}': #{e.message}") end