Module: Mokio::FrontendHelpers::ExternalScriptsHelper
- Defined in:
- lib/mokio/frontend_helpers/external_scripts_helper.rb
Overview
Frontend helper methods used with Mokio::ExternalScripts objects
Instance Method Summary collapse
-
#build_all_external_scripts ⇒ Object
Variables *
result
- all external scripts from mokio_external_scripts. -
#build_common(obj, html_comments = false) ⇒ Object
build a single external script html.
-
#build_external_script(script_name) ⇒ Object
Attributes.
Instance Method Details
#build_all_external_scripts ⇒ Object
Variables
-
result
- all external scripts from mokio_external_scripts
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mokio/frontend_helpers/external_scripts_helper.rb', line 28 def build_all_external_scripts html = "" result = Mokio::ExternalScript.all unless result.blank? result.each do |position| html = build_common(position) end end html.html_safe end |
#build_common(obj, html_comments = false) ⇒ Object
build a single external script html
Attributes
-
obj
- single external script object from ActiveRecord query result
Variables
-
obj.script
- external script content from mokio_external_scripts -
obj.name
- external script name from mokio_external_scripts
50 51 52 53 54 55 56 57 58 |
# File 'lib/mokio/frontend_helpers/external_scripts_helper.rb', line 50 def build_common(obj, html_comments = false) html = "" unless obj.blank? html << "<!--#{obj.name} - EXTERNAL SCRIPT START-->\n" if html_comments html << obj.script + "\n" html << "<!--#{obj.name} END -->\n" if html_comments html.html_safe end end |
#build_external_script(script_name) ⇒ Object
Attributes
-
script_name
- external script name from mokio_external_scripts
15 16 17 18 19 |
# File 'lib/mokio/frontend_helpers/external_scripts_helper.rb', line 15 def build_external_script(script_name) result = Mokio::ExternalScript.find_by(name:script_name) html = result.blank? ? "" : build_common(result) html.html_safe end |