module RailsVueJs::ViewHelper

Rails VueJs View Helper

Public Instance Methods

rails_vue_js() click to toggle source
# File lib/rails_vue_js/view_helper.rb, line 4
def rails_vue_js
  content = javascript_include_tag(vue_js_src)
  content += javascript_include_tag(vue_router_src)
  Dir[rails_vue_path].each do |path|
    content += render file: path
  end
  content += javascript_include_tag('rails_vue_js')
  content.html_safe
end

Private Instance Methods

rails_vue_path() click to toggle source
# File lib/rails_vue_js/view_helper.rb, line 28
def rails_vue_path
  Rails.root.join('app/vue/**/*.{slim,haml,erb,html}')
end
vue_js_src() click to toggle source
# File lib/rails_vue_js/view_helper.rb, line 16
def vue_js_src
  if Rails.env.production?
    'https://cdn.jsdelivr.net/npm/vue'
  else
    'https://cdn.jsdelivr.net/npm/vue/dist/vue.js'
  end
end
vue_router_src() click to toggle source
# File lib/rails_vue_js/view_helper.rb, line 24
def vue_router_src
  'https://unpkg.com/vue-router/dist/vue-router.js'
end