繁体   English   中英

将变量插入到从不同目录声明的 .html.slim 文件中

[英]Inserting variables into .html.slim file that are declared from a different directory

我是 Ruby 的新手。 我有一个 .html.slim 文件,其中包含一些我想用另一个 .rb 文件中声明的变量替换的数值。 我有这个粗略的设置:

company/app/views/landing_pages_hello/_hello.html.slim
company/lib/random/variables.rb

公司/lib/random/variables.rb

class A
  MY_SALARY = 5000
end

company/app/views/landing_pages_hello/_hello.html.slim

table
  tbody
    tr
      td
        = ...
        title=("My salary is $5000")

所以,我想知道我怎么取代“5000”中的_hello.html.slim与变量文件MY_SALARYvariables.rb文件。

Rails 入门指南解释了如何将变量从控制器传递到视图 我建议现在阅读该指南的大部分内容。 当您了解更多信息时,您还需要阅读其他指南。

Slim 文档解释了如何在视图中使用变量。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM