lib/hamlit/helpers.rb in hamlit-1.1.1 vs lib/hamlit/helpers.rb in hamlit-1.2.0
- old
+ new
@@ -27,9 +27,23 @@
s.gsub!(/\n/, '
')
s.delete!("\r")
s
end
+ def surround(front, back = front, &block)
+ output = capture_haml(&block)
+
+ "#{front}#{output.chomp}#{back}\n"
+ end
+
+ def precede(str, &block)
+ "#{str}#{capture_haml(&block).chomp}\n"
+ end
+
+ def succeed(str, &block)
+ "#{capture_haml(&block).chomp}#{str}\n"
+ end
+
# NOTE: currently Hamlit::Helpers is enabled by default on only
# Rails environment. Thus you can use capture.
def capture_haml(*args, &block)
capture(*args, &block)
end