Module: Ziya::HtmlHelpers::Base
Instance Method Summary collapse
- #escape_chars ⇒ Object
- #escape_once(html) ⇒ Object
-
#escape_url(url) ⇒ Object
escape url.
- #mime ⇒ Object
- #plugin_url ⇒ Object
-
#setup_movie_size(options) ⇒ Object
Check args for size option in the format wXy (Submitted by Sam Livingston-Gray).
-
#setup_wmode(options) ⇒ Object
Set the wmode to opaque if a bgcolor is specified.
- #tag_options(options, escape = true) ⇒ Object
-
#ziya_tag(name, options = nil, open = false, escape = true) ⇒ Object
All this stolen form rails to make Ziya work with other fmks.…
Instance Method Details
#escape_chars ⇒ Object
61 62 63 |
# File 'lib/ziya/html_helpers/base.rb', line 61 def escape_chars { '&' => '&', '"' => '"', '>' => '>', '<' => '<' } end |
#escape_once(html) ⇒ Object
40 41 42 |
# File 'lib/ziya/html_helpers/base.rb', line 40 def escape_once(html) html.to_s.gsub(/[\"><]|&(?!([a-zA-Z]+|(#\d+));)/) { |special| escape_chars[special] } end |
#escape_url(url) ⇒ Object
escape url
31 32 33 |
# File 'lib/ziya/html_helpers/base.rb', line 31 def escape_url( url ) url ? CGI.escape( url.gsub( /&/, '&' ) ) : url end |
#mime ⇒ Object
7 |
# File 'lib/ziya/html_helpers/base.rb', line 7 def mime() "application/x-shockwave-flash"; end |
#plugin_url ⇒ Object
8 |
# File 'lib/ziya/html_helpers/base.rb', line 8 def plugin_url() "http://www.macromedia.com/go/getflashplayer"; end |
#setup_movie_size(options) ⇒ Object
Check args for size option in the format wXy (Submitted by Sam Livingston-Gray)
22 23 24 25 26 27 28 |
# File 'lib/ziya/html_helpers/base.rb', line 22 def setup_movie_size( ) if [:size] =~ /(\d+)x(\d+)/ [:width] = $1 [:height] = $2 .delete :size end end |
#setup_wmode(options) ⇒ Object
Set the wmode to opaque if a bgcolor is specified. If not set to transparent mode unless user overrides it
12 13 14 15 16 17 18 19 |
# File 'lib/ziya/html_helpers/base.rb', line 12 def setup_wmode( ) if [:bgcolor] [:wmode] = "opaque" unless [:wmode] else [:wmode] = "transparent" unless [:wmode] [:bgcolor] = "#FFFFFF" end end |
#tag_options(options, escape = true) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ziya/html_helpers/base.rb', line 44 def (, escape = true) unless ! or .empty? attrs = [] if escape .each do |key, value| next unless value key = key.to_s value = escape_once(value) attrs << %(#{key}="#{value}") end else attrs = .map { |key, value| %(#{key}="#{value}") } end " #{attrs.sort * ' '}" unless attrs.empty? end end |
#ziya_tag(name, options = nil, open = false, escape = true) ⇒ Object
All this stolen form rails to make Ziya work with other fmks.…
36 37 38 |
# File 'lib/ziya/html_helpers/base.rb', line 36 def ziya_tag(name, = nil, open = false, escape = true) "<#{name}#{(, escape) if }" + (open ? ">" : " />") end |