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 23 def initialize(prefix = nil) 24 @start_re = /(\\*)\{#{prefix}(\w+)(::?)/ 25 @end_re = /(\\*)\{#{prefix}(\w+)\}/ 26 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 114 def parse_params(param_string, tag) 115 YAML::load("--- #{param_string}") 116 rescue ArgumentError, SyntaxError, YAML::SyntaxError => e 117 raise Error.new("Could not parse parameter string '#{param_string}' for tag '#{tag}': #{e.message}") 118 end