Skip to content

Instantly share code, notes, and snippets.

@LeoShi
Forked from mimosz/helper.rb
Created January 28, 2012 03:14
Show Gist options
  • Select an option

  • Save LeoShi/1692313 to your computer and use it in GitHub Desktop.

Select an option

Save LeoShi/1692313 to your computer and use it in GitHub Desktop.

Revisions

  1. Howl Wong created this gist Jan 19, 2012.
    16 changes: 16 additions & 0 deletions helper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    def show_props(str)
    props = str.split(';') # 切割
    if props.is_a?(Array)
    str = "<dl class='props'>"
    props.each do |property|
    prop_arr = property.split(':') # 切割
    if prop_arr.is_a?(Array) && prop_arr.count == 4
    str += "<dt title='#{prop_arr[0]}'>#{prop_arr[2]}</dt><dd title='#{prop_arr[1]}'>#{prop_arr[3]}</dd>"
    else
    str += "<dt class='warning'>提示:</dt><dd>无属性</dd>"
    end
    end
    str += "</dl>"
    end
    str
    end