Module: BootstrapViewportMetaHelper

Defined in:
app/helpers/bootstrap_viewport_meta_helper.rb

Instance Method Summary collapse

Instance Method Details

#viewport_meta_tag(*args) ⇒ Object

Creates the meta tag for Bootstrap with the specified parameters:

<%= viewport_meta_tag %>

Renders:

<meta content="width=device-width,initial-scale=1.0" name="viewport" />

You can change the content value by passing a hash as an argument:

<%= viewport_meta_tag(:maximum_scale => "1.0") %>

Renders:

<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0" name="viewport" />


19
20
21
22
23
24
25
26
# File 'app/helpers/bootstrap_viewport_meta_helper.rb', line 19

def viewport_meta_tag(*args)
  options = {
    width: "device-width",
    initial_scale: "1.0" }.merge(args[0] || {})

    content = options.collect {|key,value| "#{key.to_s.dasherize}=#{value}"}.join(",")
    raw(tag(:meta, name: "viewport", content: content))
end