展开

关键词

在Puppet中用ERB模板来自动配置Nginx虚拟主机

模板文件是在puppet模块下面templates目录中以”.erb”结尾的文件,puppet模板主要用于文件,例如各种服务的配置文件,相同的服务,不同的配置就可以考虑使用模板文件,例如Nginx和Apache 的虚拟主机配置就可以考虑采用ERB模板,nginx的安装在这里建议用系统内部自带的YUM源来安装或其它第三方YUM源来安装,如果是用Nginx的官方源来安装nginx的话,我们可以查看下/etc/yum.repos.d files |      |-- manifests |      |  `-- init.pp |      `-- templates |          |-- nginx.conf.erb ,owner => root,group => root, path => "/etc/nginx/nginx.conf", content=> template("nginx/nginx.conf.erb     file{ "/etc/nginx/conf.d/${sitedomain}.conf":         content => template("nginx/nginx_vhost.conf.erb

4710

share write up

views |-- devise | |-- confirmations | |-- mailer | |-- passwords | |-- registrations | | `-- new.html.erb | |-- sessions | | `-- new.html.erb | |-- shared | `-- unlocks |-- file |-- home | |-- Alphatest.erb | |-- addtest.erb | |-- home.erb | |-- index.html.erb | |-- publiclist.erb | |-- share.erb | `-- upload.erb |-- layouts | |-- application.html.erb | |-- mailer.html.erb | `-- mailer.text.erb `-- recommend `-- show.erb hint2: <%= render template: "home/"+params[:page] %> 从hint2可以明确(看到hint1其实可以猜测)的知道需要跨目录上传文件到

37920
  • 广告
    关闭

    腾讯云校园大使火热招募中!

    开学季邀新,赢腾讯内推实习机会

  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    Rails MVC 和 CRUD(15)

    命令汇总 rails server -b 0.0.0.0 rails generate controller welcome index cat app/views/welcome/index.html.erb rails g controller articles cat app/controllers/articles_controller.rb cat app/views/articles/new.html.erb cat app/views/articles/show.html.erb cat app/views/articles/new.html.erb cat app/models/article.rb cat app/controllers/articles_controller.rb cat app/views/articles/new.html.erb cat app/views/articles/edit.html.erb cat app/views/articles/index.html.erb ---- 原文地址

    8440

    Rails MVC 和 CRUD(5)

    root@h202 blog]# 刷新页面 这次报错,是视图中找不到对应的模板 ---- 创建模板 [root@h202 blog]# vim app/views/articles/new.html.erb [root@h202 blog]# cat app/views/articles/new.html.erb

    Test blog http://soft.dog/

    [root@h202 约定优于配置 的设计,这里的目录地址,和文件命名都是有意义的 app/views 是默认的视图存放处 articles/new 是 articles#new 方法默认去寻找的视图 new.html.erb 文件中后面的扩展名 .html.erb 也包含了意义,html 指定模板类型,erb 指定用来处理模板的程序 再次刷新 这次没有报错,获得了我指定的内容

    7520

    Rails布局和视图渲染

    = Book.all end end 基于“多约定,少配置”原则,在 index 动作末尾并没有指定要渲染的视图,Rails会自动在控制器的视图文件夹中寻找 action_name.html.erb " render action: "edit.html.erb" render "books/edit" render "books/edit.html.erb" render template: "books 如果没有 .erb 布局,Rails会使用 .builder 布局。 布局渲染局部视图 _link_area.html.erb ,此时局部布局与局部视图保存在同一个文件夹中。 new.html.erb

    New zone

    <%= render partial: "form", locals: {zone: @zone} %> edit.html.erb <h1

    22530

    Rails MVC 和 CRUD(3)

    create app/controllers/welcome_controller.rb route get 'welcome/index' invoke erb create app/views/welcome create app/views/welcome/index.html.erb invoke test_unit [root@h202 blog]# cat app/views/welcome/index.html.erb

    My first test

    Find me in app/views /welcome/index.html.erb

    [root@h202 blog]# ---- 设置首页 路由决定哪个控制器会接受到这个请求 [root@h202 blog]# vim config 127.0.0.0/127.255.255.255 Processing by WelcomeController#index as HTML Rendered welcome/index.html.erb

    8230

    从Web开发者的视角来解读MVC架构

    Rails (Ruby) Express (JS) Backbone (JS) Angular (JS) Laravel (PHP) Zend (PHP) Codeigniter (PHP) Django (Python ) Flask (Python) 接着,我们重点来讨论Ruby on Rails和Codeigniter(PHP)。 虽然类似并借用了Django for Python的某些概念,但是这两个框架实际上并没有严格的文件夹结构。 对于Ruby on Rails而言,我们可以使用嵌入式的ERB(https://ruby-doc.org/stdlib/libdoc/erb/rdoc/ERB.html)。 而对于Ruby语言,我们也可以使用Haml(http://haml.info/)和针对Python的Flask(http://flask.pocoo.org/)。

    27120

    Rails 构建评论功能(11)

    javascripts/comments.coffee cat app/assets/stylesheets/comments.scss cat app/views/articles/show.html.erb cat app/controllers/comments_controller.rb cat app/views/articles/show.html.erb cat app/views/comments /_comment.html.erb cat app/views/articles/show.html.erb cat app/views/comments/_form.html.erb cat app /views/articles/show.html.erb cat app/views/comments/_comment.html.erb cat app/controllers/comments_controller.rb

    10430

    Rails MVC 和 CRUD(10)

    [root@h202 blog]# cat app/views/articles/index.html.erb

    Listing articles

    table> [root@h202 blog]# 访问 /articles ---- 添加链接 [root@h202 blog]# vim app/views/articles/index.html.erb [root@h202 blog]# cat app/views/articles/index.html.erb

    Link test!!!! article.text %>

    <% end %>
    [root@h202 blog]# vim app/views/articles/show.html.erb [root@h202 blog]# cat app/views/articles/new.html.erb

    Test blog http://soft.dog/

    <%= form_for

    7110

    Rails 容器与配置(3)

    .keep app/views/ app/views/articles/ app/views/articles/_form.html.reb app/views/articles/edit.html.erb app/views/articles/index.html.erb app/views/articles/new.html.erb app/views/articles/show.html.erb app /views/comments/ app/views/comments/_comment.html.erb app/views/comments/_form.html.erb app/views/layouts / app/views/layouts/application.html.erb app/views/welcome/ app/views/welcome/index.html.erb bin/ bin

    7720

    Rails 构建评论功能(5)

    修改视图和控制器 [root@h202 blog]# vim app/views/articles/show.html.erb [root@h202 blog]# cat app/views/articles /show.html.erb

    Title: <%= @article.title %>

    Text:</strong (:comment).permit(:commenter, :body) end end [root@h202 blog]# vim app/views/articles/show.html.erb [root@h202 blog]# cat app/views/articles/show.html.erb

    Title: <%= @article.title

    11030

    Rails 构建评论功能(7)

    再次访问,显示效果不变 再将评论的表单也抽出 [root@h202 blog]# vim app/views/comments/_form.html.erb [root@h202 blog]# cat app/views/comments/_form.html.erb <%= form_for([@article, @article.comments.build]) do |f| %>

    <%= f.submit %>

    <% end %> [root@h202 blog]# vim app/views/articles/show.html.erb [root@h202 blog]# cat app/views/articles/show.html.erb

    Title: <%= @article.title

    7630

    Rails 构建评论功能(6)

    如果程序中重复代码达到一定量级,会影响可读性和可维护性,这时我们可以将其中重复部分抽出来,单独成块 [root@h202 blog]# vim app/views/comments/_comment.html.erb [root@h202 blog]# cat app/views/comments/_comment.html.erb

    Commenter: Comment: <%= comment.body %>

    [root@h202 blog]# vim app/views/articles/show.html.erb [root@h202 blog]# cat app/views/articles/show.html.erb

    Title: <%= @article.title

    9030

    Rails MVC 和 CRUD(13)

    params.require(:article).permit(:title,:text) end end [root@h202 blog]# vim app/views/articles/index.html.erb [root@h202 blog]# cat app/views/articles/index.html.erb

    Link test!!!! <% end %> [root@h202 blog]# [root@h202 blog]# vim app/views/articles/show.html.erb [root@h202 blog]# cat app/views/articles/show.html.erb

    Title: <%= @article.title

    6810

    Puppet管理Nginx主机

    files ├── manifests │  ├── conf.pp │  ├── init.pp │  └── install.pp └── templates     ├── nginx.conf.erb     └── vhost.erb 三:配置解释 install.pp为安装nginx的配置文件 [root@master manifests]# cat install.pp class nginx => "644",         path => "/etc/nginx/conf.d/${filename}",         content => template("nginx/vhost.erb     include nginx::install,nginx::conf } templates下面为nginx配置文件模板: [root@master templates]# cat vhost.erb

    7310

    Rails MVC 和 CRUD(6)

    添加表单 使用 form_for 来构造一个简单表单 [root@h202 blog]# vim app/views/articles/new.html.erb [root@h202 blog]# cat app/views/articles/new.html.erb

    Test blog http://soft.dog/

    <%= form_for :article do |f| %> 而这个页面 (Restfull API) 应该是用来进行显示的,而不是进行处理的 我们进行一下调整 [root@h202 blog]# vim app/views/articles/new.html.erb [root@h202 blog]# cat app/views/articles/new.html.erb

    Test blog http://soft.dog/

    <%= form_for

    6920

    FMEN | NTIRE2021-ESR最低内存占用超分方案

    此外,作者在EISR常用的残差模块基础上提出了ERB(Enhanced Residual Block)以加速模型推理速度。 组合上述设计理念记得到了本文所提FMEN与FMEN-S。 为解决上述问题,基于序贯式结构,本文提出ERB与HFAB分别用于深层特征学习与特征增强,不仅可降低内存占用,同时可加速推理效率。 2Experiments 上图对比了基于ResBlock、PlainBlock以及ERB的EDSR与FMEN性能,可以看到:相比ResBlock,ERB具有与其相当的性能,而PlainBloc则出现了严重性能下降 而在推理阶段,ERB可以折叠而PlainBlock形式并享受其高推理效率特征。 上表对比了ResBlock与ERB在不同超分模型的推理效率对比,可以看到:相比ResBlock,ERB模块的推理效率平均快10%左右。

    8410

    python五十七课——正则表达式(边界字符)

    ,'never')) print(re.search(r'erB','never')) print(re.search(r'erB','nerver')) print(re.search(r'erB'

    20310

    Forklift ETL 基础(一)(2)

    connections/mysql/destination.yml") template('email.yml', "#{p}/config/email.yml") template('email.erb ', "#{p}/template/email.erb") template('plan.rb', "#{p}/plan.rb") end def template(source connections/mysql/destination.yml") template('email.yml', "#{p}/config/email.yml") template('email.erb ', "#{p}/template/email.erb") template('plan.rb', "#{p}/plan.rb") end 整个过程就是在当前目录中创建若干目录 -rwxr-xr-x 1 root rvm 89 Aug 9 15:12 destination.yml -rwxr-xr-x 1 root rvm 29 Aug 9 15:12 email.erb

    9620

    扫码关注腾讯云开发者

    领取腾讯云代金券