简体   繁体   English

PHP包含在Ruby on Rails中?

[英]PHP Includes in Ruby on Rails?

Ive been learning PHP and tried to get into RoR and the two are always compared.My question is, is there a PHP include equivalent for Ruby on Rails. 我一直在学习PHP,并试图进入RoR并且两者总是进行比较。我的问题是,是否有一个PHP包括Ruby on Rails的等价物。 To me the ability to include PHP files is it's most valuable feature. 对我来说,包含PHP文件的能力是它最有价值的功能。

PHP is a programming language while Ruby on Rails is a framework therefore you're comparing two completely different things. PHP是一种编程语言,而Ruby on Rails是一个框架,因此你要比较两个完全不同的东西。

Assuming that you use include in PHP to build a page from many nested templates/scripts then partials would be the way to go in Rails, eg: 假设您使用PHP中的include从许多嵌套模板/脚本构建页面,那么部分将成为Rails的方法,例如:

<%= render :partial => 'sidebar' %>

Ruby itself has also require which behaves similar to include or require in PHP but it doesn't work for views in Rails. Ruby本身也require在PHP中具有类似于includerequire行为,但它不适用于Rails中的视图。

我相信最接近的等价物将是:部分

对于代码而不是标记,Ruby的模块概念也可以包括工作方式。

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

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