Skip to content

Commit

Permalink
Merge pull request #3044 from AlchemyCMS/handlebars-npm
Browse files Browse the repository at this point in the history
Use Handlebars templates from npm
  • Loading branch information
tvdeyen authored Sep 19, 2024
2 parents 2d1161d + cda0815 commit fd611ad
Show file tree
Hide file tree
Showing 16 changed files with 50 additions and 9 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app/javascript/alchemy_admin/templates/compiled.js
1 change: 0 additions & 1 deletion alchemy_cms.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ Gem::Specification.new do |gem|
gem.add_runtime_dependency "dragonfly", ["~> 1.4"]
gem.add_runtime_dependency "dragonfly_svg", ["~> 0.0.4"]
gem.add_runtime_dependency "gutentag", ["~> 2.2", ">= 2.2.1"]
gem.add_runtime_dependency "handlebars_assets", ["~> 0.23"]
gem.add_runtime_dependency "importmap-rails", ["~> 1.2", ">= 1.2.1"]
gem.add_runtime_dependency "jquery-rails", ["~> 4.0", ">= 4.0.4"]
gem.add_runtime_dependency "kaminari", ["~> 1.1"]
Expand Down
2 changes: 0 additions & 2 deletions app/assets/javascripts/alchemy/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
// ------------------------------
//= require jquery3
//= require_tree ../../../../vendor/assets/javascripts/jquery_plugins/
//= require handlebars
//= require alchemy/templates
//= require alchemy/alchemy.dialog
//= require alchemy/alchemy.image_overlay
2 changes: 0 additions & 2 deletions app/assets/javascripts/alchemy/templates/index.js

This file was deleted.

4 changes: 4 additions & 0 deletions app/javascript/alchemy_admin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import "handlebars"
import "@ungap/custom-elements"
import "@hotwired/turbo-rails"

Expand Down Expand Up @@ -26,6 +27,9 @@ import {
// Web Components
import "alchemy_admin/components"

// Handlebars Templates
import "alchemy_admin/templates/compiled"

// Shoelace Setup
import "alchemy_admin/shoelace_theme"

Expand Down
4 changes: 3 additions & 1 deletion app/javascript/alchemy_admin/node_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ function displayNodeFolders() {
}

if (list.children.length > 0 || node.folded) {
leftIconArea.innerHTML = HandlebarsTemplates.node_folder({ node: node })
leftIconArea.innerHTML = Handlebars.templates["node_folder.hbs"]({
node: node
})
} else {
leftIconArea.innerHTML = " "
}
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/alchemy_admin/page_sorter.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function displayPageFolders() {
}

if (list.children.length > 0 || page.folded) {
pageFolderEl.outerHTML = HandlebarsTemplates.page_folder({ page })
pageFolderEl.outerHTML = Handlebars.templates["page_folder.hbs"]({ page })
} else {
pageFolderEl.innerHTML = ""
}
Expand Down
1 change: 1 addition & 0 deletions app/javascript/alchemy_admin/templates/compiled.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions config/importmap.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pin "@ungap/custom-elements", to: "ungap-custom-elements.min.js", preload: true # @1.3.0
pin "clipboard", to: "clipboard.min.js", preload: true
pin "flatpickr", to: "flatpickr.min.js", preload: true # @4.6.13
pin "handlebars", to: "handlebars.min.js", preload: true # @4.7.8
pin "keymaster", to: "keymaster.min.js", preload: true
pin "sortablejs", to: "sortable.min.js", preload: true # @1.15.1
pin "@hotwired/turbo-rails", to: "turbo.min.js", preload: true
Expand Down
1 change: 0 additions & 1 deletion lib/alchemy_cms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
require "cancan"
require "dragonfly"
require "gutentag"
require "handlebars_assets"
require "importmap-rails"
require "jquery-rails"
require "kaminari"
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"eslint": "eslint app/javascript/**/*.js",
"build:js": "rollup -c",
"build:css": "sass --style=compressed --source-map --load-path app/assets/stylesheets --load-path vendor/assets/stylesheets app/assets/stylesheets/alchemy/admin.scss:app/assets/builds/alchemy/admin.css app/assets/stylesheets/alchemy/admin/print.scss:app/assets/builds/alchemy/admin/print.css app/assets/stylesheets/alchemy/welcome.scss:app/assets/builds/alchemy/welcome.css app/assets/stylesheets/tinymce/skins/content/alchemy/content.scss:app/assets/builds/tinymce/skins/content/alchemy/content.min.css app/assets/stylesheets/tinymce/skins/ui/alchemy/skin.scss:app/assets/builds/tinymce/skins/ui/alchemy/skin.min.css app/assets/stylesheets/alchemy/admin/page-select.scss:app/assets/builds/alchemy/admin/page-select.css",
"build": "bun run --bun build:js && bun run --bun build:css"
"handlebars:compile": "handlebars app/javascript/alchemy_admin/templates/*.hbs -f app/javascript/alchemy_admin/templates/compiled.js -o -m",
"build": "bun run --bun build:js && bun run --bun build:css && bun run --bun handlebars:compile"
},
"keywords": [],
"author": "Thomas von Deyen",
Expand All @@ -17,6 +18,7 @@
"@ungap/custom-elements": "^1.3.0",
"clipboard": "^2.0.11",
"flatpickr": "^4.6.13",
"handlebars": "^4.7.8",
"keymaster": "^1.6.2",
"sortablejs": "^1.15.2",
"tinymce": "^7.3.0"
Expand Down
7 changes: 7 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ export default [
plugins: [resolve(), terser()],
context: "window"
},
{
input: "node_modules/handlebars/dist/handlebars.min.js",
output: {
file: "vendor/javascript/handlebars.min.js"
},
context: "window"
},
{
input: "node_modules/keymaster/keymaster.js",
output: {
Expand Down
29 changes: 29 additions & 0 deletions vendor/javascript/handlebars.min.js

Large diffs are not rendered by default.

0 comments on commit fd611ad

Please sign in to comment.