@api public
Used by #escape_html @api private
# File lib/temple/utils.rb, line 61 def contains_static?(exp) case exp[0] when :multi exp[1..-1].any? {|e| contains_static?(e) } when :escape contains_static?(exp[2]) when :static true else false end end
Check if expression is empty
@param exp [Array] Temple expression @return true if expression is empty
# File lib/temple/utils.rb, line 78 def empty_exp?(exp) case exp[0] when :multi exp[1..-1].all? {|e| empty_exp?(e) } when :newline true else false end end
Returns an escaped copy of `html`.
@param html [String] The string to escape @return [String] The escaped string
# File lib/temple/utils.rb, line 20 def escape_html(html) EscapeUtils.escape_html(html.to_s) end
Returns an escaped copy of `html`. Strings which are declared as html_safe are not escaped.
@param html [String] The string to escape @return [String] The escaped string
# File lib/temple/utils.rb, line 11 def escape_html_safe(html) html.html_safe? ? html : escape_html(html) end
Generate unique variable name
@param prefix [String] Variable name prefix @return [String] Variable name
# File lib/temple/utils.rb, line 55 def unique_name(prefix = nil) @unique_name ||= 0 prefix ||= (@unique_prefix ||= self.class.name.gsub('::', '_').downcase) "_#{prefix}#{@unique_name += 1}" end