Class: Embryo::TemplateSupport
- Inherits:
-
Object
- Object
- Embryo::TemplateSupport
- Defined in:
- lib/embryo/template_support.rb
Instance Method Summary collapse
-
#initialize(filesystem) ⇒ TemplateSupport
constructor
A new instance of TemplateSupport.
- #install ⇒ Object
- #javascript_data ⇒ Object
- #layout_data ⇒ Object
- #messages_data ⇒ Object
- #navigation_data ⇒ Object
- #stylesheet_data ⇒ Object
Constructor Details
#initialize(filesystem) ⇒ TemplateSupport
Returns a new instance of TemplateSupport.
3 4 5 |
# File 'lib/embryo/template_support.rb', line 3 def initialize(filesystem) @filesystem = filesystem end |
Instance Method Details
#install ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/embryo/template_support.rb', line 7 def install @filesystem.require_gem "haml", "~> 4.0" @filesystem.require_gem "haml-rails", ">= 0" @filesystem.require_gem "bootstrap-sass", "~> 3.0" @filesystem.write "app/views/layouts/application.html.haml", layout_data @filesystem.write "app/views/layouts/_navigation.html.haml", @filesystem.write "app/views/layouts/_messages.html.haml", @filesystem.write "app/assets/javascripts/application.js", javascript_data @filesystem.write "app/assets/stylesheets/bootstrap-custom.css.scss", stylesheet_data @filesystem.delete "app/views/layouts/application.html.erb" end |
#javascript_data ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/embryo/template_support.rb', line 63 def javascript_data '//= require jquery //= require jquery_ujs //= require bootstrap //= require turbolinks //= require_tree . ' end |
#layout_data ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/embryo/template_support.rb', line 19 def layout_data '!!! 5 %html(lang="en") %head %meta(charset="utf-8") %meta(http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1") %meta(name="viewport" content="width=device-width, initial-scale=1.0") %title ' + @filesystem.application_human_name + ' = stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true = javascript_include_tag "application", "data_turbolinks_track" => true = csrf_meta_tags %body(role="document") = render "layouts/navigation" .container(role="main") = render "layouts/messages" = yield ' end |
#messages_data ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/embryo/template_support.rb', line 54 def '- {notice: "success", alert: "danger"}.each do |flash_key, alert_type| - if flash[flash_key].present? .alert(class="alert-#{alert_type}") %button.close(type="button" data-dismiss="alert" aria-hidden="true") × = flash[flash_key] ' end |
#navigation_data ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/embryo/template_support.rb', line 38 def '.navbar.navbar-inverse.navbar-fixed-top(role="navigation") .container .navbar-header %button.navbar-toggle(type="button" data-toggle="collapse" data-target=".navbar-collapse") %span.sr-only Toggle navigation %span.icon-bar %span.icon-bar %span.icon-bar = link_to "' + @filesystem.application_human_name + '", root_path, class: "navbar-brand" .navbar-collapse.collapse %ul.nav.navbar-nav %li= link_to "Home", root_path ' end |
#stylesheet_data ⇒ Object
72 73 74 75 76 77 |
# File 'lib/embryo/template_support.rb', line 72 def stylesheet_data '@import "bootstrap"; @import "bootstrap/theme"; body { padding-top: 70px; } ' end |