Module: Repres::HyperText::ApplicationHelper

Defined in:
app/helpers/repres/hyper_text/application_helper.rb

Overview

Application Helper 是为 HTML 页面生成标签的视图辅助模块。

Instance Method Summary collapse

Instance Method Details

#domain_name(name, options) ⇒ Object

获取 JS 库或 CSS 库的 CDN 域名。如果没有指定 CDN 域名,则采用系统缺省的 CDN 域名。



62
63
64
# File 'app/helpers/repres/hyper_text/application_helper.rb', line 62

def domain_name(name, options)
  defined?(options) ? options.try(:[], name).try(:[], :cdn)||Repres::HyperText::CDN : Repres::HyperText::CDN
end

#hyper_text_icon(options = {}) ⇒ Object

呈现 icon 相关的 HTML 代码。用于 <head></head> 之中。如:<head>

<%= hyper_text_icon %>

</head>



25
26
27
# File 'app/helpers/repres/hyper_text/application_helper.rb', line 25

def hyper_text_icon(options = {})
  render partial: 'repres/hyper_text/icon', locals: { options: options }
end

#hyper_text_meta(options = {}) ⇒ Object

呈现 meta 相关的 HTML 代码。用于 <head></head> 之中。如:<head>

<%= hyper_text_meta %>

</head>



34
35
36
# File 'app/helpers/repres/hyper_text/application_helper.rb', line 34

def hyper_text_meta(options = {})
  render partial: 'repres/hyper_text/meta', locals: { options: options }
end

#hyper_text_script(options = {}) ⇒ Object

呈现 script 相关的 HTML 代码。用于 <body></body> 结束之前。如:<body>

<header></header>
<main></main>
<footer></footer>
<%= hyper_text_script %>

</body>



46
47
48
# File 'app/helpers/repres/hyper_text/application_helper.rb', line 46

def hyper_text_script(options = {})
  render partial: 'repres/hyper_text/script', locals: { options: options }
end

#hyper_text_style(options = {}) ⇒ Object

呈现 style 相关的 HTML 代码。用于 <head></head> 结束之前。如:<head>

<title>Page Title</title>
<%= hyper_text_style %>

</head>



56
57
58
# File 'app/helpers/repres/hyper_text/application_helper.rb', line 56

def hyper_text_style(options = {})
  render partial: 'repres/hyper_text/style', locals: { options: options }
end

#library_enabled?(name, options) ⇒ Boolean

以 name 对应的值为键从 options 这个 Hash 中获取对应的值。

Returns:

  • (Boolean)


8
9
10
# File 'app/helpers/repres/hyper_text/application_helper.rb', line 8

def library_enabled?(name, options)
  defined?(options) && options.try(:[], name).present?
end

#library_version(name, default_version, options) ⇒ Object

以 name 对应的值为键从 options 这个 Hash 中获取对应的版本号。如果 options 为空,或者 options 中没有指定️版本号,则返回 default_version 对应的版本号。如:library_version ‘bootstrap’, ‘3.0’, {}



16
17
18
# File 'app/helpers/repres/hyper_text/application_helper.rb', line 16

def library_version(name, default_version, options)
  defined?(options) ? options.try(:[], name).try(:[], :version)||default_version : default_version
end