lib/liquidoc.rb in liquidoc-0.8.0 vs lib/liquidoc.rb in liquidoc-0.8.1
- old
+ new
@@ -662,20 +662,22 @@
return output
end
# Parse given data using given template, generating given output
def liquify datasrc, template_file, output, variables=nil
- data = get_data(datasrc)
+ input = get_data(datasrc)
+ nested = { "data" => get_data(datasrc)}
+ input.merge!nested
validate_file_input(template_file, "template")
if variables
vars = { "vars" => variables }
- data.merge!vars
+ input.merge!vars
end
begin
template = File.read(template_file) # reads the template file
template = Liquid::Template.parse(template) # compiles template
- rendered = template.render(data) # renders the output
+ rendered = template.render(input) # renders the output
rescue Exception => ex
message = "Problem rendering Liquid template. #{template_file}\n" \
"#{ex.class} thrown. #{ex.message}"
@logger.error message
raise message
@@ -1006,9 +1008,13 @@
# Downcase
# Turn unwanted chars into the seperator
s = input.to_s.downcase
s.gsub!(/[^a-zA-Z0-9\-_\+\/]+/i, "-")
s
+ end
+
+ def regexreplace input, regex, replacement=''
+ input.to_s.gsub(Regexp.new(regex), replacement.to_s)
end
end
# register custom Liquid filters