gpt4 book ai didi

javascript - 如何自定义 Rails 应用程序模板

转载 作者:行者123 更新时间:2023-11-28 02:31:53 26 4
gpt4 key购买 nike

我试图将我的应用分成两个版本。一种是使用 CDN,另一种是使用 Assets 脚本和 css。

对于 CDN,我是否可以将所有 CDN 线路拆分到其他文件并在 application.haml 中设置链接以使其干净。

这里是 application.haml(或 html)

%html
%head
%meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
= csrf_meta_tags
%link{:href => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css", :rel => "stylesheet"}/
Optional Theme
%link{:href => "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css", :rel => "stylesheet"}/
%link{:href => "https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css", :rel => "stylesheet"}/
%link{:href => "https://cdnjs.cloudflare.com/ajax/libs/admin-lte/2.4.2/css/AdminLTE.css", :rel => "stylesheet"}/
%link{:href => "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css\n", :rel => "stylesheet"}/
%link{:href => "https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic", :rel => "stylesheet"}/

%script{:crossorigin => "anonymous", :integrity => "sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=", :src => "https://code.jquery.com/jquery-3.2.1.min.js"}
%script{:crossorigin => "anonymous", :integrity => "sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=", :src => "https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"}
%script{:src => "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.13.0/popper.min.js"}
%script{:crossorigin => "anonymous", :integrity => "sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa", :src => "//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"}
%script{:src => "https://cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.js"}
%script{:src => "https://cdnjs.cloudflare.com/ajax/libs/jQuery-slimScroll/1.3.8/jquery.slimscroll.js"}
%script{:src => "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.3/moment.min.js"}

= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
= javascript_include_tag "application", 'data-turbolinks-track': 'reload'


%body.hold-transition.skin-yellow.sidebar-mini
.wrapper
= render "layouts/navigation/header"
= render "layouts/navigation/sidebar"
.content-wrapper
= yield
= render 'layouts/navigation/footer'

最佳答案

您可以为使用单独 Assets 的其他版本创建一个单独的 Controller 。

创建 versionb_controller.rb 并更新 routes.rb

添加文件夹/views/versionb

添加你的 View /views/versionb/index.html.erb

最后,在布局下添加您其他版本的布局并另存为 /layouts/versionb.html.erb

关于javascript - 如何自定义 Rails 应用程序模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47646070/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com