Class: Typekit::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Typekit::Generators::InstallGenerator
- Defined in:
- lib/typekit/generators/install_generator.rb
Instance Method Summary collapse
-
#inject_into_layout ⇒ Object
def inject_view_helper application_controller_path = ‘app/controllers/application_controller.rb’ if ::File.exists?(::File.join(destination_root, application_controller_path)) inject_into_file application_controller_path, after: “class ApplicationController < ActionController::Basen” do “ helper :typekitn” end end end.
- #inject_javascript ⇒ Object
Instance Method Details
#inject_into_layout ⇒ Object
def inject_view_helper
application_controller_path = 'app/controllers/application_controller.rb'
if ::File.exists?(::File.join(destination_root, application_controller_path))
inject_into_file application_controller_path, after: "class ApplicationController < ActionController::Base\n" do
" helper :typekit\n"
end
end
end
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/typekit/generators/install_generator.rb', line 26 def inject_into_layout application_layout_path_prefix = 'app/views/layouts/application.html' api_key = ask 'What is your kit ID (leave blank to specify later):' api_key = '- YOUR KIT ID HERE -' if api_key.blank? layout_templates = { slim: { content: " = typekit '#{api_key}'", after: "head\n" }} layout_templates[:erb] = { content: " <%#{layout_templates[:slim][:content].lstrip} %>", after: "<head>\n" } layout_templates.each_pair do |lang,| path = ::File.join(destination_root, "#{application_layout_path_prefix}.#{lang}") if ::File.exists?(path) inject_into_file path, after: [:after] do "#{[:content]}\n" end end end end |
#inject_javascript ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/typekit/generators/install_generator.rb', line 8 def inject_javascript application_js_path = 'app/assets/javascripts/application.js' if ::File.exists?(::File.join(destination_root, application_js_path)) inject_into_file application_js_path, before: '//= require_tree' do "//= require typekit\n" end end end |