diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9ff1f0c..f4dff50 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,3 +13,4 @@
- Vue on Rails application template using `rails new app -m https://vueonrails.com/vue -d postgresql`
- Support Babel 7
- Support webpack 4 & Webpacker 4
+- Support pre-processor like pug
diff --git a/README.md b/README.md
index fba7786..62c9619 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,24 @@

-> Vue for your favorite Rails projects
+> Vue for your favorite Rails products
-The Vue on Rails gem makes it easy to build Vue components on your Rails application.
+The Vue on Rails gem makes it easy to build Vue components on your Rails products.
It uses Rails 5.x, Vue 2.x, Webpacker 4.x, Ruby 2.x, Node 11.x, Yarn 1.12.x.
-- ❄️ Server Side Rendering using Hypernova
-- 💎 Compatible with Rails 6/5/4 and Webpacker
-- 🌎 Internationalization for component parts
- 🖖 Vue UI ready
-- 🔨 Component generators and scaffolds
-- 📦 Out of the box configuration
-- ✂️ Specific-page Vue
+- 🐶 Support pug
- 🤡 Jest test ready
+- ✂️ Specific-page Vue
+- 👷🏻️ Asset pipeline helpers
- 🎯 Simple state management
+- 📦 Out of the box configuration
+- 🔨 Component generators and scaffolds
+- ❄️ Server Side Rendering using Hypernova
- 🗃 Easily migrate to Vuex state management
-- 👷🏻️ Asset pipeline helpers
-- 🏎 Kickstart with our Vue on Rails application template at https://vueonrails.com/vue
+- 🌎 Internationalization for component parts
+- 💎 Compatible with Rails 6/5/4 and Webpacker
+- 🏎 Kickstart with our application template at https://vueonrails.com/vue
It ships out-of-the-box configuration, component generators and other solutions to make life easy for both Vue and Rails.
diff --git a/app/helpers/syntax_helper.rb b/app/helpers/syntax_helper.rb
index 31dd5a0..18ba7ff 100644
--- a/app/helpers/syntax_helper.rb
+++ b/app/helpers/syntax_helper.rb
@@ -1,5 +1,3 @@
-require 'hypernova'
-
module SyntaxHelper
def specific_page_vue
" #{controller_name} #{action_name} "
@@ -29,7 +27,7 @@ def vue_component(identifier, variable=nil)
end
#server side rendering via hypernova
- def render_vue(id, name)
- render_react_component(id, name: name)
+ def render_vue_component(id, data = {})
+ render_react_component(id, data)
end
end
diff --git a/lib/generators/options/pug.rb b/lib/generators/options/pug.rb
new file mode 100644
index 0000000..910a57b
--- /dev/null
+++ b/lib/generators/options/pug.rb
@@ -0,0 +1,14 @@
+pugtemplate = <<-eos
+
+ ##{name}
+ p {{ message }}
+
+eos
+
+if options[:seperate] == true
+ gsub_file Rails.root.join("#{PARTS_PATH}/#{name}/#{name}.vue").to_s,
+ /[^\]]*<\/template>/, pugtemplate
+else
+ gsub_file Rails.root.join("#{PARTS_PATH}/#{name}.vue").to_s,
+ /[^\]]*<\/template>/, pugtemplate
+end
diff --git a/lib/generators/templates/I18n/cn.yml b/lib/generators/templates/i18n/cn.yml
similarity index 100%
rename from lib/generators/templates/I18n/cn.yml
rename to lib/generators/templates/i18n/cn.yml
diff --git a/lib/generators/templates/I18n/index.js b/lib/generators/templates/i18n/index.js
similarity index 100%
rename from lib/generators/templates/I18n/index.js
rename to lib/generators/templates/i18n/index.js
diff --git a/lib/generators/templates/ssr/component.js.erb b/lib/generators/templates/ssr/component.js.erb
index c9416b5..607460c 100644
--- a/lib/generators/templates/ssr/component.js.erb
+++ b/lib/generators/templates/ssr/component.js.erb
@@ -1,5 +1,5 @@
// Generated by Vue on Rails https://github.com/vueonrails/vueonrails
-// Embed this component
+// To embed this component in Rails view, use <%= render_vue_component "component.js" %>
// To generate this component, run `rails generate vue something --ssr`
console.log("Hello, <%= name %>")
diff --git a/lib/generators/vue/vue_generator.rb b/lib/generators/vue/vue_generator.rb
index 31c750f..dde7ec7 100644
--- a/lib/generators/vue/vue_generator.rb
+++ b/lib/generators/vue/vue_generator.rb
@@ -19,6 +19,7 @@ class VueGenerator < Rails::Generators::NamedBase
table: {type: :boolean, default: false},
modal: {type: :boolean, default: false},
click: {type: :boolean, default: false},
+ pug: {type: :boolean, default: false}
}.freeze
class_option :ssr, type: :string, default: nil
diff --git a/lib/installs/loaders/pug.js b/lib/installs/loaders/pug.js
new file mode 100644
index 0000000..1a145e9
--- /dev/null
+++ b/lib/installs/loaders/pug.js
@@ -0,0 +1,15 @@
+// Generated by Vue on Rails https://github.com/vueonrails/vueonrails
+// This is required to support Pug in Vue on Rails.
+
+module.exports = {
+ test: /\.pug$/,
+ oneOf: [
+ {
+ resourceQuery: /^\?vue/,
+ use: ['pug-plain-loader']
+ },
+ {
+ use: ['raw-loader', 'pug-plain-loader']
+ }
+ ]
+}
diff --git a/lib/installs/pug.rb b/lib/installs/pug.rb
new file mode 100644
index 0000000..a72a16e
--- /dev/null
+++ b/lib/installs/pug.rb
@@ -0,0 +1,12 @@
+# install pug dependencies
+run "yarn add pug pug-plain-loader"
+
+# add the pug loader
+copy_file "#{__dir__}/loaders/pug.js", Rails.root.join("config/webpack/loaders/pug.js").to_s
+
+# insert pug into the environment.js
+insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
+"const pug = require('./loaders/pug')\n", after: "require('@rails/webpacker')\n"
+
+insert_into_file Rails.root.join("config/webpack/environment.js").to_s,
+"environment.loaders.prepend('pug', pug)\n", before: "module.exports = environment"
diff --git a/lib/installs/setup.rb b/lib/installs/setup.rb
index f5af030..15129ad 100644
--- a/lib/installs/setup.rb
+++ b/lib/installs/setup.rb
@@ -1,8 +1,8 @@
# Check for the lack of .babelrc or webpacker 4
def check_version_and_babel
#should i check for evidence of webpacker:install?
- File.exists?(Rails.root.join(".babelrc")) == false \
- || (Gem.loaded_specs["webpacker"].version < Gem::Version.new('4.x')) == false
+ (File.exists?(Rails.root.join(".babelrc")) == true) \
+ || ((Gem.loaded_specs["webpacker"].version >= Gem::Version.new('4.x')) == false)
end
begin
@@ -33,10 +33,16 @@ def check_version_and_babel
"const alias = require('./alias/alias')\n", after: "require('@rails/webpacker')\n"
# Add *_pack_tag into application.html.erb This is essential for specific-page vue setup.
-pack_tag = <<-eos
- <%= javascript_pack_tag 'application' %>
- <%= stylesheet_pack_tag 'application' %>
-eos
+if (Gem.loaded_specs["rails"].version >= Gem::Version.new('6.x')) # rails 6 has default javascript_pack_tag
+ pack_tag = <<-eos
+ <%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+ eos
+else # non-rails 6
+ pack_tag = <<-eos
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+ <%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+ eos
+end
insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
pack_tag, before: " \n"
@@ -83,19 +89,6 @@ def check_version_and_babel
insert_into_file Rails.root.join("package.json").to_s,
scripts, after: "\"private\": true,\n"
-babelrc = <<-eos
- "env": {
- "test": {
- "presets": [
- ["env", { "targets": { "node": "current" }}]
- ]
- }
- },
-eos
-
-insert_into_file Rails.root.join(".babelrc").to_s,
-babelrc, before: " \"presets\": ["
-
# Insert locale.js as a default i18n and add second locale cn.yml
copy_file "#{__dir__}/../generators/templates/i18n/index.js", Rails.root.join("app/javascript/locales/locale.js").to_s
copy_file "#{__dir__}/../generators/templates/i18n/cn.yml", Rails.root.join("config/locales/cn.yml").to_s
diff --git a/lib/installs/spv.rb b/lib/installs/spv.rb
index 9639959..9721903 100644
--- a/lib/installs/spv.rb
+++ b/lib/installs/spv.rb
@@ -3,10 +3,17 @@
gsub_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
/<\/body>/, '<% end %>'
-pack_tag = <<-eos
- <%= javascript_pack_tag 'application' %>
- <%= stylesheet_pack_tag 'application' %>
-eos
+if (Gem.loaded_specs["rails"].version >= Gem::Version.new('6.x')) # rails 6 has default javascript_pack_tag
+ pack_tag = <<-eos
+ <%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+ eos
+else # non-rails 6
+ pack_tag = <<-eos
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+ <%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
+ eos
+end
+
insert_into_file Rails.root.join("app/views/layouts/application.html.erb").to_s,
pack_tag,
@@ -18,4 +25,4 @@
insert_into_file Rails.root.join("app/assets/javascripts/application.js").to_s,
vue_on_rails,
-before: "//= require_tree ."
\ No newline at end of file
+before: "//= require_tree ."
diff --git a/lib/installs/ssr/component.js b/lib/installs/ssr/component.js
index 3ce8a7f..6b7a77f 100644
--- a/lib/installs/ssr/component.js
+++ b/lib/installs/ssr/component.js
@@ -1,3 +1,7 @@
+// Generated by Vue on Rails https://github.com/vueonrails/vueonrails
+// To embed this component in Rails view, use <%= render_vue_component "component.js" %>
+// To generate this component, run `rails generate vue something --ssr`
+
console.log("hello, component")
const Vue = require("vue")
const renderVue = require("hypernova-vue").renderVue
diff --git a/lib/installs/ssr/ssr.js b/lib/installs/ssr/ssr.js
index 7cdea9f..9c3c248 100644
--- a/lib/installs/ssr/ssr.js
+++ b/lib/installs/ssr/ssr.js
@@ -1,9 +1,13 @@
+// Generated by Vue on Rails https://github.com/vueonrails/vueonrails
+// To run this script, simply run `node ssr`
+
var hypernova = require('hypernova/server');
hypernova({
devMode: true,
getComponent(name) {
- // console.log("The component name is -> " + name)
+ // Console.log("The component name is -> " + name)
+ // Make sure you state the corresponding name correctly. In this case, 'component.js'
if (name === 'component.js') {
return require('./app/javascript/ssr/component.js')
}
diff --git a/lib/installs/test.rb b/lib/installs/test.rb
index 9512c11..adb624a 100644
--- a/lib/installs/test.rb
+++ b/lib/installs/test.rb
@@ -28,16 +28,4 @@
"#{scripts}",
after: "\"private\": true,\n"
-babelrc = <<-eos
- "test": {
- "presets": [
- ["env", { "targets": { "node": "current" }}]
- ]
- },
-eos
-
-insert_into_file Rails.root.join(".babelrc").to_s,
- "#{babelrc}",
- before: " \"presets\": ["
-
-run "yarn add jest-serializer-vue vue-jest babel-jest --no-progress --silent"
\ No newline at end of file
+run "yarn add jest-serializer-vue vue-jest babel-jest --no-progress --silent"
diff --git a/lib/vueonrails/version.rb b/lib/vueonrails/version.rb
index 7e8f009..b36a3c5 100644
--- a/lib/vueonrails/version.rb
+++ b/lib/vueonrails/version.rb
@@ -1,3 +1,3 @@
module Vueonrails
- VERSION = "0.3.0"
+ VERSION = "1.0.0.beta4"
end
diff --git a/logo.png b/logo.png
new file mode 100644
index 0000000..4062358
Binary files /dev/null and b/logo.png differ