Module: LayoutHelper
- Defined in:
- lib/generators/squeezer/templates/app/helpers/layout_helper.rb
Overview
These helper methods can be called in your template to set variables to be used in the layout This module should be included in all views globally, to do so you may need to add this line to your ApplicationController
helper :layout
Instance Method Summary collapse
- #javascript(*args) ⇒ Object
- #link_to(*args, &block) ⇒ Object
- #show_title? ⇒ Boolean
- #stylesheet(*args) ⇒ Object
- #title(page_title, show_title = true) ⇒ Object
- #wysiwug ⇒ Object
Instance Method Details
#javascript(*args) ⇒ Object
19 20 21 |
# File 'lib/generators/squeezer/templates/app/helpers/layout_helper.rb', line 19 def javascript(*args) content_for(:head) { javascript_include_tag(*args) } end |
#link_to(*args, &block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/generators/squeezer/templates/app/helpers/layout_helper.rb', line 29 def link_to(*args, &block) if block_given? = args.first || {} = args.second link_to(capture(&block), , ) else name = args[0] = args[1] || {} = args[2] = (, ) url = url_for() if (url.split('/').last == url.split('/')[1]) action ="index" else action = url.split('/').last if action.to_i > 0 action = "show" if args[2] if args[2][:method] action = "destroy" end end end end #controller = url.split('/')[1].chop.capitalize href = ['href'] = () href_attr = "href=\"#{ERB::Util.html_escape(url)}\"" unless href classes="class='sq-#{action}'" #if(can?(action.to_sym, controller) || controller >="User") "<a #{classes} #{href_attr}#{}>#{ERB::Util.html_escape( name || url)}</a>".html_safe #end end end |
#show_title? ⇒ Boolean
11 12 13 |
# File 'lib/generators/squeezer/templates/app/helpers/layout_helper.rb', line 11 def show_title? @show_title end |
#stylesheet(*args) ⇒ Object
15 16 17 |
# File 'lib/generators/squeezer/templates/app/helpers/layout_helper.rb', line 15 def stylesheet(*args) content_for(:head) { stylesheet_link_tag(*args) } end |
#title(page_title, show_title = true) ⇒ Object
6 7 8 9 |
# File 'lib/generators/squeezer/templates/app/helpers/layout_helper.rb', line 6 def title(page_title, show_title = true) @content_for_title = page_title.to_s @show_title = show_title end |
#wysiwug ⇒ Object
23 24 25 26 27 |
# File 'lib/generators/squeezer/templates/app/helpers/layout_helper.rb', line 23 def wysiwug content_for(:head) { javascript_include_tag('jquery.cleditor.min')} content_for(:head) { stylesheet_link_tag('CLEditor1_3_0/jquery.cleditor')} raw "<script>$(function(){$('.wysiwyg').cleditor();});</script>" end |