Module: ExvoGlobalize::Helpers
- Defined in:
- lib/exvo_globalize/helpers.rb
Instance Method Summary collapse
-
#HashToHTML(hash, opts = {}) ⇒ Object
Prints nested Hash as a nested <ul> and <li> tags - keys are wrapped in <strong> tags - values are wrapped in <span> tags.
-
#i18n_translations_javascript_include_tag(locale) ⇒ Object
Outputs the javascript include tag with translations in the selected language (locale param) in the js format.
Instance Method Details
#HashToHTML(hash, opts = {}) ⇒ Object
Prints nested Hash as a nested <ul> and <li> tags
-
keys are wrapped in <strong> tags
-
values are wrapped in <span> tags
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/exvo_globalize/helpers.rb', line 7 def HashToHTML(hash, opts = {}) return if !hash.is_a?(Hash) indent_level = opts.fetch(:indent_level) { 0 } out = " " * indent_level + "<ul>\n" hash.each do |key, value| out += " " * (indent_level + 2) + "<li><strong>#{key}:</strong>" if value.is_a?(Hash) out += "\n" + HashToHTML(value, :indent_level => indent_level + 2) + " " * (indent_level + 2) + "</li>\n" elsif value.is_a?(Array) out += " <span>[ #{value.join(', ')} ]</span></li>\n" elsif value.is_a?(Proc) out += " <span>" + CGI::escapeHTML(value.to_s) + "</span></li>\n" else out += " <span>#{value}</span></li>\n" end end out += " " * indent_level + "</ul>\n" end |
#i18n_translations_javascript_include_tag(locale) ⇒ Object
Outputs the javascript include tag with translations in the selected language (locale param) in the js format
32 33 34 |
# File 'lib/exvo_globalize/helpers.rb', line 32 def i18n_translations_javascript_include_tag(locale) javascript_include_tag("/globalize/translations/js/#{locale}.js") end |