       date.format("M/D/YY#{if time then ' h:mm A' else ''}")
 
   @label: (text, type) ->
-    type = if type then "#{type} " else ''
+    css_classes = ['label', text.replace(/\s+/g, '-'), type].compact()
 
     $('<span>')
       .text(text)
-      .prop('class', "label #{type}#{text}".toLowerCase().dasherize())
+      .prop('class', css_classes.join(' ').toLowerCase().dasherize())
 
   @icon: (types) ->
     classes = ("fa-#{type}" for type in types.split(' ')).join(' ')
 
     "<i class=\"fa #{classes}\"></i>"
+
+  @escapeHtml: (string) ->
+    return '' if string is null or string is undefined
+
+    String(string).replace /[&<>"'`=\/]/g, (s) -> Fustrate.entityMap[s]
+
+  @multilineEscapeHtml: (string) ->
+    return '' if string is null or string is undefined
+
+    String(string)
+      .split(/\r?\n/)
+      .map (line) -> Fustrate.escapeHtml(line)
+      .join '<br />'
 
 # Replicate a few common prototype methods on String and Array
 String::titleize = ->


      elem.addClass 'negative' if parseInt(number, 10) < 0

  # Take a string like 'Asgard.Whiteboard.Entry' and retrieve the real class
  # with that name. Start at `window` and work down from there.
  @_stringToClass: (string) ->
    pieces = string.split('.')

      beforeSend: (xhr) ->
        $.rails.CSRFProtection xhr

  @getCurrentPageJson: ->
    pathname = window.location.pathname.replace(/\/+$/, '')

    $.get "#{pathname}.json#{window.location.search}"

  @humanDate: (date, time = false) ->
    if date.year() is moment().year()
      date.format("M/D#{if time then ' h:mm A' else ''}")
