lib/prez/helpers.rb in prez-0.0.5 vs lib/prez/helpers.rb in prez-0.0.6
- old
+ new
@@ -4,10 +4,14 @@
module Prez
module Helpers
protected
+ def reset_helpers!
+ @duration = nil
+ end
+
def duration(value)
if @duration
raise Prez::Error.new("The duration helper can only be called once!")
end
@@ -46,11 +50,31 @@
else
seconds.to_s
end
end
- def html_escape(value)
- CGI.escape_html value
+ def html_escape(value = nil, &block)
+ if block
+ value = capture &block
+ end
+
+ value = CGI.escape_html value
+
+ if block
+ concat value
+ else
+ value
+ end
+ end
+
+ def capture()
+ buf = ""
+ old_buffer = @output_buffer
+ @output_buffer = buf
+ yield
+ buf.to_s
+ ensure
+ @output_buffer = old_buffer
end
def slide(options = {})
classes = ["prez-slide"]
align = options.fetch :align, :center